after the databind, tryTable t = (Table)DataGrid1.Controls[0];
string s = t.Rows[0].Cells[1].Text;

解决方案 »

  1.   

    超出范围?
    你是不是没有先绑定就执行取headertext代码?
    试一下:
    //...
    DataGrid1.DataBind();
    //...你要取headertext的代码
      

  2.   

    当datagrid的属性设置为 AutoGenerateColumn = true时候
    after the databind, tryTable t = (Table)DataGrid1.Controls[0];
    string s = t.Rows[0].Cells[1].Text;s的值为空。怎么办。
      

  3.   

    DataGrid1.DataSource = ....;
    DataGrid1.DataBind();
    Table t = (Table)DataGrid1.Controls[0];
    string s = t.Rows[0].Cells[1].Text;s的值为空??
      

  4.   

    columns.count值时为0 当然会超出索引了
     绑定之后取一下columns.count看看是多少先
      

  5.   

    DataGrid1.DataSource = ....;
    DataGrid1.DataBind();
    Table t = (Table)DataGrid1.Controls[0];
    string s = t.Rows[0].Cells[1].Text;s的值为空??是的,当 DataGrid 的 AllowSorting=true的时候这个时候如何取呢?