开发者

Cell Index of a GridView Cell

开发者 https://www.devze.com 2023-04-05 22:20 出处:网络
开发者_JAVA技巧I\'m a novice in .Net. I w8ish to know how to get index of a cell just like getting row index of a row after accessing the GridView.A cell is accessed by getting a reference to the row

开发者_JAVA技巧I'm a novice in .Net. I w8ish to know how to get index of a cell just like getting row index of a row after accessing the GridView.


A cell is accessed by getting a reference to the row and iterating through its cells.

Say for example that you are handling the RowDataBound Event, this is how you access the cells:

 protected void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
  {

    if(e.Row.RowType == DataControlRowType.DataRow)
    {

      //e.Row.RowIndex will tell you the current row index
      foreach (TableCell cell in e.Row.Cells)
      {
            //do something with the cell
      }

    }

  }
0

精彩评论

暂无评论...
验证码 换一张
取 消