Netlink2
asked on
How to set RadioButtonList value via table
Hi, I have a radio button with the following code
<legend>Garage:</legend>
<asp:RadioButtonList runat="server" ID="radioGarage">
<asp:ListItem Value="1" >Yes</asp:ListItem>
<asp:ListItem Value="2" Selected="True">No</asp:Li stItem>
</asp:RadioButtonList>
I don't know how to change the selected value based upon a database request.
It's part of a formview, which is:
<asp:FormView ID="AdFormView" runat="server" DataSourceID="AdDataSource " DefaultMode="Edit"
DataKeyNames="Id" OnItemUpdating="AdFormView _ItemUpdat ing">
I'm not even sure what I should be saving to the database, other texts and labels are using Bind, i.e..
'<%# Bind("Garage") %>'
<legend>Garage:</legend>
<asp:RadioButtonList runat="server" ID="radioGarage">
<asp:ListItem Value="1" >Yes</asp:ListItem>
<asp:ListItem Value="2" Selected="True">No</asp:Li
</asp:RadioButtonList>
I don't know how to change the selected value based upon a database request.
It's part of a formview, which is:
<asp:FormView ID="AdFormView" runat="server" DataSourceID="AdDataSource
DataKeyNames="Id" OnItemUpdating="AdFormView
I'm not even sure what I should be saving to the database, other texts and labels are using Bind, i.e..
'<%# Bind("Garage") %>'
Use Databound property of this control and also then set the selected value at code behind
ASKER
Thanks Qaiser, I suppose the question is how do I do this ?. Can you provide an example in code ?.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I gave up on trying and just used checkboxes instead.
<legend>Garage:</legend>
<asp:RadioButtonList runat="server" ID="radioGarage" SelectedValue='<%# Bind("YOUR_DATA_FIELD_NAME
<asp:ListItem Value="1" >Yes</asp:ListItem>
<asp:ListItem Value="2" Selected="True">No</asp:Li
</asp:RadioButtonList>