webressurs
asked on
RadioButtonList / DropDownList: Show selected
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.Co nnString)
Dim cmd As New SqlCommand("spShowType", conn)
cmd.CommandType = CommandType.StoredProcedur e
cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.radTypeList.DataSource = dr
Me.radTypeList.DataTextFie ld = "content"
Me.radTypeList.DataValueFi eld = "typeID"
'Me.radTypeList.SelectedIn dex = savedID
Me.radTypeList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
"SelectedIndex" does not check the radiobutton where datavaluefiled = savedID...
Thanks for all tips!!!
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.Co
Dim cmd As New SqlCommand("spShowType", conn)
cmd.CommandType = CommandType.StoredProcedur
cmd.Connection.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Me.radTypeList.DataSource = dr
Me.radTypeList.DataTextFie
Me.radTypeList.DataValueFi
'Me.radTypeList.SelectedIn
Me.radTypeList.DataBind()
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
"SelectedIndex" does not check the radiobutton where datavaluefiled = savedID...
Thanks for all tips!!!
If savedID is same value as "TypeID" then use
Me.radTypeList.SelectedVal ue = savedID
Me.radTypeList.SelectedVal
ASKER
I get the errormessage "Selectedvalue is not a member of System.Web.UI.WebControls. RadioButto nList" when I try that...
Since you have installed .net 1.1, guess the above problem will be resolved.
Just realised that you are the one created the another thread.
Just realised that you are the one created the another thread.
ASKER
Hello,
This is the way, framework 1.0 dont support the property SelectedValue:
Me.radTypeList.Items.FindB yValue(sav edID).Sele cted = True
Thanks for all tips :)
This is the way, framework 1.0 dont support the property SelectedValue:
Me.radTypeList.Items.FindB
Thanks for all tips :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use radTypeList.SelectedValue = savedID instead, the selectedindex only selects (doesn't check) whereas setting the selected value does.
Tim Cottee