ButtonField弹出消息框 OnClientClick="return confirm('确定要删除么?');" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <asp:TemplateField HeaderText="删除"> <ItemTemplate> <asp:LinkButton ID="DepLB" CommandName="DepLB" CommandArgument='<%#Bind("id")%>' runat="server" OnClientClick="return confirm('确定要删除么?');" Text="删除"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> 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('确定要删除么?')"); } } } 也可在Page_Load中添加代码现实:btn.Attributes.Add("onclick", "return confirm('确定要删除么?')"); 运算符“-”无法应用于“string”和“int”类型的操作数 怎么把动态添加的htmlControl设置为服务器控件????????急,在线等,解决马上给分 access中如何获得刚插入的行的id值 如何动态指定事件 关于Asp.net中自定义事件,望高人指教,小弟不胜感激!!!!!!! 高手请进! asp.net母板 关于Web Control TreeView ,怎样添加它的单击事件? 弱弱的问:还是关于弹出框,怎么把这些代码组合? 在ASP.NET中不刷新页面的情况下实现存取SERVER端的数据。 如何asp.net中获取数据库版本 Forms验证无法重定向问题
<ItemTemplate>
<asp:LinkButton ID="DepLB" CommandName="DepLB" CommandArgument='<%#Bind("id")%>' runat="server" OnClientClick="return confirm('确定要删除么?');" Text="删除"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
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('确定要删除么?')");
}
}
}
btn.Attributes.Add("onclick", "return confirm('确定要删除么?')");