How to retrieve data from database to radiobuttonlist? [Resolved]

Posted by Hariinakoti under ASP.NET on 1/23/2013 | Points: 10 | Views : 6412 | Status : [Member] | Replies : 3
Hi All,
I saved radiobutton list value in database like "Male" or "Female".Now i want to retrieve that data from database to radiobuttonlist.If Male in database i want to check the Radionbuttonlist(Male) value other wise uncheck the radiobuttonlist(Female) value.

Thanks & Regards
Hari



Responses

Posted by: Hariinakoti on: 1/23/2013 [Member] Starter | Points: 25

Up
0
Down

Resolved
Thank You All.
I got Solution.
rdbgender.SelectedIndex = Convert.ToInt32(rdbgender.Items.IndexOf(rdbgender.Items.FindByText(ds.Tables[0].Rows[0]["Gender"].ToString())));

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 1/23/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Please elaborate it more .It is not clear.

If this post helps you mark it as answer
Thanks

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 1/23/2013 [Member] Bronze | Points: 25

Up
0
Down
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
selectRB('F'); //calling function
}

public void SelectRB(char Option)
{
if (Option == 'M')
{
Rb.SelectedIndex = 0; // Selects Male
}
else
{
Rb.SelectedIndex = 1; // Selects Female
}
}
}

<asp:RadioButtonList ID="Rb" runat="server" AutoPostBack="false">
<asp:ListItem Text="Male" Value="M"></asp:ListItem>
<asp:ListItem Text="Female" Value="F"></asp:ListItem>
</asp:RadioButtonList>

This helps you, Mark Answer if this helps you

Thanks
Pavan Kumar
Mark Answer if this fits the need

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response