Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating multiple querystrings from drop down lists - Could be 1, 2 or 3 querystrings. How do I do it?
    text
    copied!<p>I have a gridview which can be filtered from one or more values in a querystring. That all works great: e.g. <code>"?subject=Maths&amp;authorName=Bond_James&amp;type=Magazine"</code></p> <p>The values passed to the query string come from 3 drop down lists: Subject, Author, Type. What I'd like is when the user presses "Filter" it will take the selected values from the drop down lists and pass them to the querystring - it could be 1 value, 2, or all 3 (like above).</p> <p>The drop down lists have an item called "All Subjects" / "All Author" / "All Type" each with a value of -1. The idea being that if the user leaves these items selected then the Filter button just ignores them.</p> <p>Here is my code so far:</p> <pre><code> Protected Sub buttonFilterGo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonFilterGo.Click Dim queryString As String Dim selectedAuthorString As String = "author=" &amp; dropAuthorList.SelectedItem.Value Dim selectedSubjectString As String = "subject=" &amp; dropSubjectList.SelectedItem.Value Dim selectedTypeString As String = "type=" &amp; dropPaperType.SelectedItem.Value Const PATH As String = "~/paper/browse/?" queryString = selectedAuthorString &amp; "&amp;" &amp; selectedSubjectString &amp; "&amp;" &amp; selectedTypeString If IsNothing(queryString) Then labelFilterFeedback.Text = "Apply some filters then press Go" Else Response.Redirect(PATH &amp; queryString) labelFilterFeedback.Text = "" End If End Sub </code></pre> <p>Also, one more thing. How do I get the drop down lists to have the filters selected when the page re loads?</p> <p>I'd really appreciate any help!</p> <p><strong>EDIT: I changed the default values of the drop down lists to "" - this leaves the URL looking messy though <code>?author=&amp;subject=&amp;type=</code> This works, is it the best way?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload