Click here to Skip to main content
15,887,425 members
Please Sign up or sign in to vote.
3.18/5 (3 votes)
See more:
Hello everyone,

I have one page which displays gridview with data calculated on page load which have two columns one with checkbox and other with radiobutton. I have taken this two fields as a templatefield. I want to get the values of radiobutton and checkbox for all the rows ON BUTTON CLICK. How to get this values?
Posted

1 solution

for (int i = 0; i < GrivdView.Rows.Count; i++)
            {
                CheckBox cBox = (CheckBox)grdUsers.Rows[i].Cells[1].FindControl("checkbox");//Write the ID of you CheckBox here in FindControl and write the correct cell index into Cells[1]
                if (cBox != null)
                {
                    //now you can play with check box
                }
                RadioButton rButton = (RadioButton)grdUsers.Rows[i].Cells[2].FindControl("");//Write the ID of you RadioButton here in FindControl and write the correct cell index into Cells[1]
                if (rButton != null)
                {
                    //now you can play with Radio Button
                }
            }
 
Share this answer
 
v2
Comments
Thanks7872 2-Aug-13 2:30am    
Thanks. This is the question i asked at the time i started coding with C# :-). Very much thankful to you that you helped me. I was new to codeproject at that time,so unaware about accepting answers. Well,this had solved my problem and hence i accepted this now in order to make this help some one else.

Regards,
Rohan Leuva

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