bbesase
bbesase

Reputation: 861

Picking specific parts out of a query string

I have a query string which has more than one value being passed through it and I need to access the second passed value... I have this as of now:

If Request.QueryString("ANBOS") IsNot Nothing Then

            Dim url As String = HttpContext.Current.Request.Url.AbsoluteUri
            Dim index As Integer = url.IndexOf("-")

            If index > 0 Then

                url = url.Substring(0, index)

            End If

            DBTable = MaterialStuff.GetComponentsForMaterial(CInt(Request.QueryString(url)))

I'm attempting here to dumb everything after the first value I need, then go back and look at the query string where it's equal to ANBOS and get its value, but when I go get the value of it, the whole query string is still there, both values...

How do I make it so I just get the first value? Any help is greatly appreciated :)

Edit: Query String being passed through

Response.Redirect("Edit.aspx?ANBOS=" & CType(flxSearchResults.SelectedItem.Cells(1).Text, Integer) & "MaterialNumberToUpdate=" & NextMaterialID)

Upvotes: 0

Views: 86

Answers (1)

mason
mason

Reputation: 32694

Your query string is being generated incorrectly

Response.Redirect("Edit.aspx?ANBOS=" & CType(flxSearchResults.SelectedItem.Cells(1).Text, Integer) & "MaterialNumberToUpdate=" & NextMaterialID)

should be..

Response.Redirect("Edit.aspx?ANBOS=" & CType(flxSearchResults.SelectedItem.Cells(1).Text, Integer) & "&MaterialNumberToUpdate=" & NextMaterialID)

This is because the query string uses ampersand signs (&) to separate key value pairs.

Upvotes: 1

Related Questions