Click here to Skip to main content
14,828,290 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a datgrid and checkbox in it as template column.I want to get the id of checked rows in a button click.

Updated 17-Nov-10 19:20pm

1 solution

for that, you have iterate through all the rows, datagrid rows, and find the checkbox and its state.

Other way, attach a javascript function to each checkbox, have some global variale at client side and put all the checked ids in it. Update it on every checkbox change event. And lastly when user clicks the button, you can get the ids from it, for that you can use hiddenvariable
Arun K V 18-Nov-10 2:28am
I had tried this.But the condition is always false
foreach (GridViewRow gvr in customersGridView.Rows)
if (((CheckBox)gvr.FindControl("chkCustomer")).Checked == true)
string strPrimaryid = gvr.Cells[1].ToString();

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