Looping through GridView rows and Checking Checkbox Control

后端 未结 2 1408
南方客
南方客 2020-12-04 01:21

I currently have a GridView which displays data from a Student Table, here is my Grid and associated SQLDataSource;

                      

        
相关标签:
2条回答
  • 2020-12-04 02:07

    Loop like

    foreach (GridViewRow row in grid.Rows)
    {
       if (((CheckBox)row.FindControl("chkboxid")).Checked)
       {
        //read the label            
       }            
    }
    
    0 讨论(0)
  • 2020-12-04 02:11

    you have to iterate gridview Rows

    for (int count = 0; count < grd.Rows.Count; count++)
    {
        if (((CheckBox)grd.Rows[count].FindControl("yourCheckboxID")).Checked)
        {     
          ((Label)grd.Rows[count].FindControl("labelID")).Text
        }
    }
    
    0 讨论(0)
提交回复
热议问题