Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi..

i have radiobuttonlist in gridview...in case of edit,i wanna see radiobuttonlist selected which are selected...how to do it...?
please help me out...
Posted

1 solution

In code behind in OnRowEditing or in OnDataBound event write following code after setting a EditIndex
C#
//define label element in edittemplate of gridview to access primry key element
Label lb = (Label)gv1.Rows[e.NewEditIndex].FindControl("lb1");
sqlQuery = "select stream from tablename where no='"+lb.Text+"'";
da = new SqlDataAdapter(sqlQuery, cn);
ds = new DataSet();
da.Fill(ds, "temp");
DataRowCollection drc = ds.Tables["temp"].Rows;
string temptext = null;
foreach (DataRow dr in drc)
{
    temptext = dr["columnname"].ToString();     //name of the column which is bound to radiobutton list
}
rb.Items.FindByText(temptext).Selected = true;
 
Share this answer
 
Comments
Member 10276220 30-Dec-13 2:22am    
its not working
Vinay Jade 30-Dec-13 7:01am    
what is the error
Vinay Jade 30-Dec-13 7:01am    
if you want i can forward complete code to you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900