TextBox labelID=(TextBox)e.Item.Cells[2].Controls[0];
这句话是不是有问题

解决方案 »

  1.   

    什么错误呢
    其次,你不用DataGrid tmpDg=(DataGrid)source;吧
    一般找ID都是通过DataKeyField来的
      

  2.   

    我想得到项模板中的控件Label的值,该怎么得到呢?
    一般:
             DataGrid tmpDg=(DataGrid)source;
    TextBox labelID=(TextBox)e.Item.Cells[2].Controls[0];
             ...........
    是得到编辑模板中的控件,但我是想得到项模板中的控件的值。
    该怎么写代码呀?
      

  3.   

    我想得到项模板中的控件Label的值,该怎么得到呢?
    一般:
             DataGrid tmpDg=(DataGrid)source;
    TextBox labelID=(TextBox)e.Item.Cells[2].Controls[0];
             ...........
    是得到编辑模板中的控件,但我是想得到项模板中的控件的值。
    该怎么写代码呀?
      

  4.   

    CheckBoxcb1=(CheckBox)dgLevel.Items[i].Cells[3].Controls[1];
    bool a=cb1.Checked;
    这是我写的,不知道对你有没有帮助
      

  5.   

    我这里有个总结,不知道对你有没有帮助
    里面阐述了模板列
    http://blog.csdn.net/brightheroes/archive/2004/11/13/180201.aspx
      

  6.   


             DataGrid tmpDg=(DataGrid)source;
    TextBox labelID=((TextBox)e.Item.Cells[2].Controls[0]).Text;
             ...........