OnClientClick="return confirm('确定要删除么?');" 

解决方案 »

  1.   

    <asp:TemplateField HeaderText="删除">
                      <ItemTemplate>
                          <asp:LinkButton ID="DepLB" CommandName="DepLB" CommandArgument='<%#Bind("id")%>' runat="server" OnClientClick="return confirm('确定要删除么?');" Text="删除"></asp:LinkButton>
                      </ItemTemplate>
                     </asp:TemplateField>
      

  2.   


    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
    //e.Row.Cells[0].Controls[0]表示ButtonField 是放在第一个单元格内的
                Button btn = e.Row.Cells[0].Controls[0] as Button;
                if (btn != null)
                {
                    btn.Attributes.Add("onclick", "return   confirm('确定要删除么?')");           
                }
                
             }
        }
      

  3.   

    也可在Page_Load中添加代码现实:
    btn.Attributes.Add("onclick", "return   confirm('确定要删除么?')");