Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
I have a gridview. In that I have four radio button with its group name. when I select any one radio button from gridview, I want the respected text of that radio button.
Posted 18-Feb-13 18:25pm
Comments
Jameel Moideen at 19-Feb-13 0:30am
   
Please post what you have tried
Dhanashree Dive at 19-Feb-13 0:33am
   
protected void lbtnsubmit_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
RadioButton rb = (GridView1.Rows[i].FindC>
<asp:listitem text='<#eval('column1')>'<asp:listitem>
ans so on. please help me.
Karthik Harve at 19-Feb-13 0:34am
   
did you tried with check change event of the radio button ?
Dhanashree Dive at 19-Feb-13 0:39am
   
I have not created radio button list. And so I m getting problem in firing any event. please tell me how should I write four radio buttons in radiobuttonlist.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
you can use RadioButtonList in the ItemTemplate of the gridview and in RowDataBound event of the gridview, you can bind the items of the list.
 
<itemtemplate>
<asp:RadioButtonList id="rbList" runat="server" AutoPostBack="false"></asp:RadioButtonList>
</itemtemplate>
protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        RadioButtonList list = (RadioButtonList)e.Row.FindControl("rbList");
        list.DataSource = objDT; //your datatable as datasource
        list.DataBind();
    }
}
protected void lbtnsubmit_Click(object sender, EventArgs e) 
{
    for (int i = 0; i < GridView1.Rows.Count; i++) 
    { 
        RadioButtonList rblist = (GridView1.Rows[i].FindControl("rbList")) as RadioButtonList; 
        if (rblist.SelectedItem != null) 
        { 
            asnw.Text = rbList.SelectedItem.Text;
        } 
    }
}
 
hope it helps
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi ,
 
Grouped Radio Buttons in Gridview[^]
 
^]
 
go with these links it ll help you.
 
Thanks
 
Neha Sharma
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 470
1 mhegazy94 460
2 Ravi Bhavnani 190
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,135
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,619
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100