Reputation: 223
I have a RadioButtonList that includes 2 values - "Yes" and "no". I want that everytime a user gets into the form page, the value will be set as the one he chose when he filled the form in the first time. I have no problem doing it with the TextBoxes, only with the RadioButtonList. Here are the codes:
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="Yes"></asp:ListItem>
<asp:ListItem Value="No"></asp:ListItem>
</asp:RadioButtonList>
the Code behind: (the 'if' checks in the DB if the user chose the "No" Radio button when he first filled the form, the ??? is what I need from you :))
if ((String)cmd3.ExecuteScalar() == "No")
{
???
}
I tried RadioButtonList1.Items.FindByValue("No").Selected = true;
but it did'nt work.
Let me know if I wasn't clear, and Thanks. Idan.
Upvotes: 0
Views: 1985
Reputation: 2525
how about:
if ((String)cmd3.ExecuteScalar() == "No")
{
RadioButtonList1.SelectedIndex = 1;
}
else
{
RadioButtonList1.SelectedIndex = 0;
}
Upvotes: 2