有一个girdview与数据库绑定,test()用来遍历girdview取里面单元格的值,但是循环遍历每次都是空值,gridview的行数和列数可以取到的。请问一下是不是我写错了。很急,在线等。
 if (!IsPostBack)
            {
                this.GridView1.DataSource = ds;
                this.GridView1.DataBind();
                test();
            }
  protected void test()
        {
            for (int i = 0; i < this.GridView1.Rows.Count; i++)
            {
                int a = this.GridView1.Rows[i].Cells.Count;
                string  k = this.GridView1.Rows[i].Cells[1].Text.Trim();
                string w = this.GridView1.Rows[i].Cells[0].Text.ToString();
                string t = this.GridView1.Rows[i].Cells[2].Text.ToString();
            }
        }