I have taken RadioButton control in every row of the GridView control to select one row
at a time. (asp.net C#)
for this i write the following code, But it is slow process, I want to best way to do this
protected void RadioButton1_CheckedChanged1(object sender, EventArgs e)
{
RadioButton SelectedRadioButton = (RadioButton)sender;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
RadioButton rb = (RadioButton)GridView1.Rows[i].FindControl("RadioButton1");
rb.Checked = false;
}
GridViewRow SelectedGridRow = (GridViewRow)SelectedRadioButton.NamingContainer; //for get the index of selected row
int RowIndex = SelectedGridRow.RowIndex;
RadioButton rb1 = (RadioButton)GridView1.Rows[RowIndex].FindControl("RadioButton1");
rb1.Checked = true;
}
is there any suggestion?
Loading

Amit ChoudharyPosted Feb 18, 2011, 2:30 AM
When we add controls in template of grid then the ID's and Names of controls different for e.g., ct1_ctl1Panel_cltGrid_Radiobtn etc. or something like that. so GroupName doesn't provide a solution.
Yes its possible in Asp.net 4.0 to use the GroupName property but not in 3.5 as 4.0 provides the property named StaticClientID='true' or similary property i don't exactly remember the name of property.
But i think in your scenario the javascript is the best solution.
Thanks.
Vikas AhlawatPosted Feb 18, 2011, 1:41 AM
it is not possible by set the GroupName
because , radio button is in every row ( not multiple button in one row)
Suthish NairPosted Feb 18, 2011, 1:04 AM
Vikas AhlawatPosted Feb 18, 2011, 12:33 AM
is it possible to do it without javascript?
Thanks for your reply.
Amit ChoudharyPosted Feb 18, 2011, 12:27 AM
Here is the complete code using the javascript radio button single row select in GridView. No server side events so it'll surely speedup your user interaction to the grid.
Please mark "Do you like this post?" if it helps you.
Thanks