简体   繁体   中英

Getting selected checkboxes in a gridview in ASP.Net

I am using a gridview in asp.net with the left column being checkboxes. How can I tell which rows have a checkbox "checked" upon button submit?

CheckBox chkBx = new CheckBox();

for (int i = 0; i < grdView.Rows.Count; ++i)
{
chkBx = (CheckBox)grdView.Rows[i].FindControl("yourCheckBoxIDInHTMLView");

 if (chkBx.Checked == true)
 {
  // Do some work here
 }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM