<p>I'd like to build a query string based on values taken from 5 groups of radio buttons.</p>

<p>Selecting any of the groups is optional so you could pick set A or B or both. How would I build the querystring based on this? I'm using VB.NET 1.1</p>

<p>The asp:Radiobuttonlist control does not like null values so I'm resorting to normal html radio buttons. My question is how do I string up the selected values into a querystring</p>

<p>I have something like this right now:</p>

<p>HTML:</p>

<pre><code>&lt;input type="radio" name="apBoat" id="Apb1" value="1" /&gt; detail1
&lt;input type="radio" name="apBoat" id="Apb2" value="2" /&gt; detail2

&lt;input type="radio" name="cBoat" id="Cb1" value="1" /&gt; detail1
&lt;input type="radio" name="cBoat" id="Cb2" value="2" /&gt; detail2
</code></pre>

<p>VB.NET</p>

<pre><code>Public Sub btnSubmit_click(ByVal sender As Object, ByVal e As System.EventArgs)
  Dim queryString As String = "nextpage.aspx?"

  Dim aBoat, bBoat, cBoat bas String

  aBoat = "apb=" &amp; Request("aBoat")
  bBoat = "bBoat=" &amp; Request("bBoat")
  cBoat = "cBoat=" &amp; Request("cBoat ")


  queryString += aBoat &amp; bBoat &amp; cBoat

  Response.Redirect(queryString)

End Sub
</code></pre>

<p>Is this the best way to build the query string or should I take a different approach altogether? Appreciate all the help I can get. Thanks much.</p>

[{'answer_id': 81678, 'author': 'Jon', 'author_id': 12261, 'author_profile': 'https://Stackoverflow.com/users/12261', 'pm_score': 0, 'selected': False, 'text': '<p>You could use StringBuilder instead of creating those three different strings. You can help it out by preallocating about how much memory you need to store your string. You could also use String.Format instead.</p>\n\n<p>If this is all your submit button is doing why make it a .Net page at all and instead just have a GET form go to nextpage.aspx for processing?</p>\n'}, {'answer_id': 81704, 'author': 'Ian Oxley', 'author_id': 1904, 'author_profile': 'https://Stackoverflow.com/users/1904', 'pm_score': 2, 'selected': True, 'text': '<p>The easiest way would be to use a non-server-side &lt;form&gt; tag with the method="get" then when the form was submitted you would automatically get the querystring you are after (and don\'t forget to add &lt;label&gt; tags and associate them with your radio buttons):</p>\n\n<pre><code>&lt;form action="..." method="get"&gt;\n    &lt;input type="radio" name="apBoat" id="Apb1" value="1" /&gt; &lt;label for="Apb1"&gt;detail1&lt;/label&gt;\n    &lt;input type="radio" name="apBoat" id="Apb2" value="2" /&gt; &lt;label for="Apb2"&gt;detail2&lt;/label&gt;\n\n    &lt;input type="radio" name="cBoat" id="Cb1" value="1" /&gt; &lt;label for="Cb1"&gt;detail1&lt;/label&gt;\n    &lt;input type="radio" name="cBoat" id="Cb2" value="2" /&gt; &lt;label for="Cb2"&gt;detail2&lt;/label&gt;\n&lt;/form&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/81628', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12232/']