日期:2014-05-18  浏览次数:20436 次

gridviw Cell问题

  for (int i = 0; i < this.grv_kecheng.Rows.Count; i++)
  {
  //课程从第一门开始循环

  GridView rowi = this.grv_kecheng.Rows[i];//取得当前行,即首行
  string kecheng = rowi.Cells[0].Text.ToString();
  Response.Write(rowi);
  }



错误:“System.Web.UI.WebControls.GridView”并不包含“Cells”的定义
有时候可以运行成功,有时候不成功,是什么原因呢?是命名空间没有使用吗?cells使用什么命名空间呢?

------解决方案--------------------
GridView rowi = this.grv_kecheng.Rows[i];//取得当前行,即首行

===========> GridViewRow rowi = this.grv_kecheng.Rows[i];//取得当前行,即首行