DataGrid里每一列都是模版列,不是绑定列,要从指定的列中取数据应该如何做呢?
我用DataGrid.Items[i].Cell[j].Text为什么取到的总是空。

解决方案 »

  1.   

    是不是应该用参数 e.Items[i].Cell[j].Text 这样啊,不妨试试
      

  2.   

    ((模版列中控件的类型)e.Item.FindControl("控件的ID")).Text
      

  3.   

    try
    {
             String strText = e.Item.FindControl("控件的ID")).Text;
    }
    catch( Exception ex )
    {
          //do nothing here...
          //Becase the first row of the column(header) do not have this control, so
         //you can not find it, and will course a exception ! or you can check if it' s not the header, then find control}
      

  4.   

    可以这样:DataGrid.Items[i].Cell[j].Control[0].Text吧
      

  5.   

    应该是偶没说清楚,偶要找的是指定行,指定列的数据。
    日月说的方法不行,DataGrid.Items[i].Cell[j].Control[0]后不能.Text了!~
      

  6.   

    摸板列得用 famousun(路漫漫其修远兮,吾将上下而求索)那样的方法:e.Item.FindControl("控件的ID")
      

  7.   

    如果用e.Item.FindControl("控件的ID")这个方法,哪一列可以确定了,但是行呢?
      

  8.   

    ((TextBox)E.Item.FindControl("Email")).Text;
      

  9.   

    TextBox txt = (TextBox)E.Item.FindControl("控件的ID");
    int row = e.EditItemIndex;//不知道是不是 这个,你查一下帮助就知道了 
    string str = txt.Text;
    e.Items[row][str];
      

  10.   

    编辑状态时 就取  e.item.cells[].controls[0]     (如果是文本框就转换为TextBox,然后取text属性,下拉框等同理)浏览状态时  取  e.item.cells[].text
      

  11.   

    这里的e是什么?DataGridCommandEventArgs??
      

  12.   

    终于搞定了,正解是:
    ControlType a=(ControlType)DataGrid1.Item[i].FindControl("controlid");
    string i=a.Text;