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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Aug 5, 2009, 9:47 AM
Use Code Like Below For Assigning Value to RadioButtonList Control in GridView
kadirPosted Aug 5, 2009, 9:08 AM
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 PatelPosted Aug 5, 2009, 8:25 AM
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 !!