ImageButton 控件放在templatefield中
在.cs文件中
ImageButton imgbtn = (ImageButton)e.Row.FindControl("imgbtnDelete");
为什么找不到,是模板列的原因吗????????

解决方案 »

  1.   

    GridViewRow gvr = (sender as ImageButton).NamingContainer as GridViewRow;
    TextBox txt=gvr.FindControl("txt") as TextBox;
    foreach(GridViewRow gr in GridView1.Rows)
    {}//FindControl
      

  2.   

    我知道为什么找不到,但是我暂时不知道怎么写。
    你可以在执行出来的页面里“查看源代码”,你会看到你的控件的ID并不是你后台代码所写的ID
    如果你要取得控件的ID的话,我想你必须是先得到具体某一行的记录后才有可能通过FindControl找到控件