如何取System.Web.UI.DataGrid的某行某列的值?通过DataGridItem.Cells取不出来嘛
foreach( DataGridItem item in DataGrid1.Items){
   check =(CheckBox) item.FindControl("chkSelected");
   if ( true == check.Checked){
       if (ViewState["GoodNumbers"].ToString().IndexOf(DataGrid1.DataKeys  [item.ItemIndex].ToString()) < 0)
       ViewState["GoodNumbers"] = ViewState["GoodNumbers"].ToString() + "'" + item.Cells[3].Text +  "',"; 
}
请高手指点喽。

解决方案 »

  1.   

    你的代码要在DATAGRID绑定的代码后使用就可以了。如果不是的话,就要用((TableCell)DataGrid.Controls[0].Controls[i].Controls[j]).Text来获得了。
      

  2.   

    DataGrid.Items[i].Cells[j].Text;
      

  3.   

    1.代码放在DataGrid1.DataBind()后面
    2.如果单元格第四列不是帮定列而是hyperlink列等,item.Cells[3].Text不行。
    比如hyperlink要用((LinkButton)item.Cells[3]).Text
      

  4.   

    这种取值还要运算的,还是模板列方便一些
    findcontrol