A small example of GridView control traversal in ES0en. net

  • 2020-06-19 10:05:04
  • OfStack


int intCount = this.GridView1.Rows.Count; // Total number of rows 
for (int i = 0; i < intCount; i++)
{
  Label1.Text = ((HyperLink)GridView1.Rows[i].Cells[0].Controls[0]).Text.ToString().Trim();

}

for (i = 0; i < GridViewID.Rows.Count; i++)
{
   CheckBox chkVote =  (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");
}

Above I use for to traverse the ridview control, now I use foreach to traverse the control.


foreach   (GridViewRow   row   in   GridView1.Rows)   
{   
    CheckBox   cb   =   (CheckBox)row.FindControl("CheckBox2");   
    if(cb.Checked==true)   
    {   
    }   
}


Related articles: