I want to use RadioButtonList in GridView for selecting i.e:yes ,no or true ,false....
thank you for helps
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 5, 2009, 4:25 AM EDT
Just Add Columns You want to Work With in Grid
1. Click on Smart Tag icon of Grid > Edit Columns Add Few Columns
2. Select Any Column and Click Convert This Field to Template and Click ok
3. Again Click on Smart Tag and Click "Edit Template"
4. Drag Drop RadioButtonList ito Item Template
6. You Are Done !!
kadir13 reputationPosted Aug 5, 2009, 5:08 AM EDT
But I don't using RadioButtonList GridView dynamically.
Value that is coming database i.e true or false.I use this value for RadioButtonList.SelectedIndex
I try to below code this process but I take error:object reference not set to an instance of an object.
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
Label1.Text = string.Empty;
getLogo();
durumDoldurediting();
}
void durumDoldurediting()
{
SqlCommand cmd4 = new SqlCommand("select LDurum from proLogo", con);
con.Open();
SqlDataReader rd = cmd4.ExecuteReader();
int i = 0;
RadioButtonList rdbl = new RadioButtonList();
while (rd.Read())
{
rdbl = (GridView1.Rows[i].FindControl("RadioButtonList2") as RadioButtonList);
if (Convert.ToBoolean(rd[0].ToString()))
{
rdbl.SelectedIndex = 0;
//(GridView1.Rows[i].FindControl("RadioButtonList") as RadioButtonList).SelectedIndex = 0;
}
else
{
rdbl.SelectedIndex = 1;
//GridView1.Rows[i].FindControl("RadioButtonList") as RadioButtonList).SelectedIndex = 1;
}
i++;
}
rd.Close();
con.Close();
}
aspx code below:
<EditItemTemplate>
EditItemTemplate>
thank you for helps
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 5, 2009, 5:47 AM EDT
Use Code Like Below For Assigning Value to RadioButtonList Control in GridView