protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ((LinkButton)e.Row.Cells[2].Controls[0]).Attributes.Add("onclick", "return confirm('确定要删除吗?')");
        }
        
    }其中的Controls[0]是什么意思,我刚刚学习。net,望高手不吝赐教,谢谢!!

解决方案 »

  1.   

    e.Row.Cells[2]里面的第一个Control
      

  2.   

    这段代码的作用就是找出GridView1中要点击的linkbutton并给该linkbutton添加onclick事件。
      

  3.   

    e.Row.Cells[2].Controls[0]行數據綁定後事件:當前行的第三列裡面的第一個控件。
      

  4.   


    // GridView控件的数据绑定事件
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
      {
      // 如果当前行是数据绑定行
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
      // 从当前行的第三个单元格中找到第一个默认的控件,添加客户端脚本的onclick事件
      ((LinkButton)e.Row.Cells[2].Controls[0]).Attributes.Add("onclick", "return confirm('确定要删除吗?')");
      }
       
      }
    其实简单来说,就是你的GridView列表第三列的删除按钮,添加一个确认删除的对话框。
      

  5.   


    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
      {
      //判断是否数据绑定行
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
      //e.Row.Cells[2].Controls[0] 找出第三列里第一个控件,把它转换 LinkButton 对象 并添加一个 onclick Js事件
      ((LinkButton)e.Row.Cells[2].Controls[0]).Attributes.Add("onclick", "return confirm('确定要删除吗?')");
      }
       
      }
      

  6.   

    每一行的第三列的LinkButton控件注册JSconfirm('确定要删除吗?')
      

  7.   

    不許拍馬屁,哼今后只回答SQL版問題!~~~