How to select a radio button from radio button group in gridview control?

Posted by Naga116 under C# on 8/17/2011 | Points: 10 | Views : 9352 | Status : [Member] | Replies : 3
At a time only one radio button i have to select from Radiobutton group in the Grid view. Each row having radio button



Select EmpNo No Department Name Amount(Rs) Pay Amount(Rs)

radiobutoongroup 3685 ABC 0.00

Dt 8449 FPQ 0.00

3649 MNO 0.00

7109 XYZ 0.00

Nagaraju


Responses

Posted by: Nisar87 on: 8/18/2011 [Member] Starter | Points: 25

Up
0
Down
hi,
to use radio button inside gridview, please refer following link

http://www.codeproject.com/KB/webforms/Radio_buttons_in_Gridview.aspx

_______________________________________
Nisar Ahmad
http://www.dotnetobject.com/

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jpchoudhari on: 8/18/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

If you are using radio button list control then you can set SelectedItem property to the item you want to select.

Kind Regards,
Jay

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rimi1289 on: 2/9/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Selecting a single radio button can be done either from the client side or from code behind.

<Columns>

<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton runat="server" id="rbRow" />
</ItemTemplate>
</asp:TemplateField>
</Columns>


Code behind (C#)

for (int index = 0; index <= GridView1.Rows.Count - 1; index++) {

// ACCESS THE RADIO BUTTONS FROM THE TEMPLATE FIELD.
RadioButton rb = (RadioButton)GridView1.Rows(index).FindControl("rbRow");

if (rb.Checked) {
You can write your code here ....
}
}


Code behind (VB)

       

For index As Integer = 0 To GridView1.Rows.Count - 1
' ACCESS THE RADIO BUTTONS FROM THE TEMPLATE FIELD.
Dim rb As RadioButton = CType(GridView1.Rows(index).FindControl("rbRow"), RadioButton)
if rb.Checked Then
You can write your code here ....
End If
Next


Using JQuery.

The link below provides a valuable article on how to select one Radio Button at a time in a GridView control and also check if any Radio Button is selected or not.

http://www.encodedna.com/2013/02/aspdotnet.gridview-row-jquery.htm

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response