troubleshooting Question

RadioButtonList / DropDownList: Show selected

Avatar of webressurs
webressursFlag for Norway asked on
6 Comments1 Solution491 ViewsLast Modified:
I am making a page to update articles.
When a radiobuttonlist is displayed, I want the stored value to be displayed as default (checked).

Example: I use a procedure to display the RadioButtonList. An input to this procedure is the ID that is stored in the database. I want the radiobuttonlist to show the radiobutton with datavaluefield = savedID as checked when it is displayed.

Private Sub getTypes(ByVal savedID)
    Dim conn As New SqlConnection(variables.ConnString)
    Dim cmd As New SqlCommand("spShowType", conn)
    cmd.CommandType = CommandType.StoredProcedure

    Dim dr As SqlDataReader = cmd.ExecuteReader
    Me.radTypeList.DataSource = dr
    Me.radTypeList.DataTextField = "content"
    Me.radTypeList.DataValueField = "typeID"
    'Me.radTypeList.SelectedIndex = savedID

End Sub

"SelectedIndex" does not check the radiobutton where datavaluefiled = savedID...

Thanks for all tips!!!

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros