我想在后台用ImageButton1,可是在cs文件中始终找不到ImageButton1,不知为什么 

解决方案 »

  1.   


    这里好像找不到ImageButton1啊
      

  2.   

    protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton imgbutton = e.Row.FindControl("ImageButton1") as ImageButton;
                
            }
        }
      

  3.   

     protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
           
        }
    在这个事件中可以找到ImageButton1吗
      

  4.   

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
      {
        ImageButton btn = sender as ImageButton  }
      

  5.   

    ImageButton imgbutton = e.Row.FindControl("ImageButton1") as ImageButton;
    你的ImageButton 在Gridview里面的 就得这么取
      

  6.   

    btn 取的就是你点击的那个imagebutton
    你自己点击输出它的Text看看就知道了。
      

  7.   

    ImageButton imgbutton = e.Row.FindControl("ImageButton1") as ImageButton;
    不知这行代码写在哪个事件里面
      

  8.   

    ImageButton btn = sender as ImageButton
    这行代码是什么意思啊
      

  9.   


    sender是事件的发起者,作为一个对象传递到函数,要实行一个转换才能得到事件发起的imagebutton
      

  10.   


    sender是触发事件的事件源,在这里就是你要点的那个按钮。