我想遍历dataGrid里面的所有数据,但我不想遍历数据源(因为这是经理要求的)代码我是这样写的
  foreach(DataRow row in this.DataGrid1.Items )
{

    strCsv = strCsv + row.Cells[0].ToString() + " , " + row.Cells[1].ToString() + " , " + row.Cells[2].ToString() + "\n" ;}但row.Cells[0].ToString 都显示  System.Web.UI.WebControls.TableCell  ,而不显示实际内容,请问有什么办法,遍历cells的内容阿,谢谢啦 分不够在加。

解决方案 »

  1.   

    上面写错了 是 foreach(DataGridItem row in this.DataGrid1.Items )
    {
    strCsv = strCsv + row.Cells[0].ToString() + " , " + row.Cells[1].ToString() + " , " + row.Cells[2].ToString() + "\n" ;
    }
      

  2.   

    把Cells[i].ToString 改成 Cells[i].Text 就好了
      

  3.   

    row.Cells[1].ToString() 得到的是什么??哈哈,
    row.Cells[1].Text.ToString() 这个得到的是什么,你试试就知道了.