Get the indexes of selected rows in GridView

前端 未结 2 1887
我在风中等你
我在风中等你 2021-02-06 14:22

I want get the rows I selected from gridview use a checkbox. The checkbox is like this!

2条回答
  •  不思量自难忘°
    2021-02-06 14:44

    You can loop through the GridView rows and use FindControl to retrieve the Checkbox and then get the IsChecked property on them.

    foreach (GridViewRow row in grid.Rows)
    {
      CheckBox check = (CheckBox)row.FindControl("CheckboxID");
    
      if (CheckBox1.Checked)
      {
       ...
      } 
    }
    

提交回复
热议问题