Click here to Skip to main content
15,790,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,
I have a grid view with number of records. Inside the grid view i have two column radio button fields. my requirement is i need to select any one of the radio button in each column record.


Radiobtn1 radiobtn2
1 1
2 2
3 3

i need to select only one radiobutton each column.

use on first radiobutton click event of first column.

radiobutton2.checked=false; //radio button of second column in gridview
and vice versa.

use it on click event of every radio button.
Share this answer
stanly jeba singh 29-Mar-12 3:01am    
it was rough
Hi Friend,

Please find the solution below.

Add the below javascript to your aspx page.

<script language="javascript" type="text/javascript">
        function SelectSingleRadiobutton(rdbtnid, id) {
            var rdBtn = document.getElementById(rdbtnid);
            var rdBtnList = document.getElementsByTagName("input");
            for (i = 0; i < rdBtnList.length; i++) {
                if (rdBtnList[i].type == "radio" && rdBtnList[i].id != {
                    var radname = rdBtnList[i].getAttribute('name');
                    var radid = radname.substring(radname.length - 4, radname.length);
                    if (radid == id)
                        rdBtnList[i].checked = false;

Hope you have two RadioButton fields / columns placed in the TemplateField of your GridView as below. Invoke the javascript in the "onclick" event of both RadioButton.

<asp:TemplateField HeaderText="Radio 1">
        <asp:RadioButton type="radio" ID="rad1" runat="server" onclick="SelectSingleRadiobutton(,'rad1');"  />
<asp:TemplateField HeaderText="Radio 2">
        <asp:RadioButton type="radio"  ID="rad2" runat="server" onclick="SelectSingleRadiobutton(,'rad2');" />

Hope this helps you!!
Share this answer
i followed these step to achieve this problem...

step: 1) first set each group for each column in the grid view

step 2) next split as per u r requirements's for radio button

for example: if we have in first column of grid view consis of one,tw0,three radio buttons properties of these associated radiobuttons set property (group=g1) this do the same steps for next column ....set for (group=g2) that

now: it will take in each column selects only one radio button .............

enjoy these.........
thanks ®ards,
Share this answer
Member 8412080 26-Apr-12 1:37am    
How to select one of radio button in a column?From upper code,the output i get is can select 1 radio button only...
Member 8412080 26-Apr-12 1:47am    
I would like to select the radio button in every row.

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