I am useing the following code, and it is obviously incorrect. I am trying to open my page with the radiobutton preset to the selection the user made on the previous page. I have confirmed that my request.querystring has the string and that this string is in fact one of the listitems in my radiobuttonlist.
Here is how I am trying to make this work:
<Code>
ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
IfNot Page.IsPostBackThen
RadioButtonList1.SelectedIndex = 0
IfNot Request.QueryString("terr")IsNothingThen
Dim myterrAsString
myterr = Server.UrlDecode(Request.QueryString("terr"))
Label2.Text = myterr
Dim itemAs ListItem
ForEach itemIn RadioButtonList1.Items
If Trim(item.Value) = Trim(myterr)Then
item.Selected =True
EndIf
Next
' RadioButtonList1.SelectedValue = Request.QueryString("terr")
EndIf
EndIf
If RadioButtonList1.SelectedIndex > -1Then
terrstring = Trim(RadioButtonList1.SelectedItem.Text)
EndIf
EndSub
</code>
Please tell me how to do this correctly.
Try that:myterr = Request.QueryString("terr").toString()
I don't understand why you are trying to decode a query string.
This might help you out:
http://forums.asp.net/1173137/ShowPost.aspx
NC...
Sorry server.urldecode was an attempt on my part to resolve this, but as I am getting the correct string value from my request, I will remove the decode. The issue I have is finding the listitem in my radiobuttonlist with the same value as the string from my request and then setting that list item to be the selected item. Currently that is not happening. The radiobuttonlist selection is not being set.
In the link that I posted, I demonstrated how to do that both from a database and without a database.
NC...
0 comments:
Post a Comment