asp.net中“单击DataGrid控件中的【删除】链接按钮时执行的事件”在哪里弄出来? 15
2个回答
展开全部
html:<asp:TemplateField HeaderText="删除">
<ItemTemplate>
<asp:LinkButton ID="linkbtn1" runat="server" CommandName="del" CommandArgument='<%#Eval("Buiding_id") %>' OnClientClick="return confirm('确定删除?一旦删除将不可恢复!');">删除</asp:LinkButton></ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="70px" />
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
.cs:protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")
{
int Buiding_id = int.Parse(e.CommandArgument.ToString());
int count;
SqlParameter[] parms = { new SqlParameter("@Buiding_id", SqlDbType.Int) };
parms[0].Value = Buiding_id;
DbHelperSQL.RunProcedure("UP_T_building_Delete", parms, out count);
if (count > 0)
{
BindData(str);
ClientScript.RegisterStartupScript(this.GetType(),"", "<script>alert('删除成功!');</script>");
}
else
{
ClientScript.RegisterStartupScript(this.GetType(),"", "<script>alert('删除失败!');</script>");
}
}
}
<ItemTemplate>
<asp:LinkButton ID="linkbtn1" runat="server" CommandName="del" CommandArgument='<%#Eval("Buiding_id") %>' OnClientClick="return confirm('确定删除?一旦删除将不可恢复!');">删除</asp:LinkButton></ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="70px" />
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
.cs:protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")
{
int Buiding_id = int.Parse(e.CommandArgument.ToString());
int count;
SqlParameter[] parms = { new SqlParameter("@Buiding_id", SqlDbType.Int) };
parms[0].Value = Buiding_id;
DbHelperSQL.RunProcedure("UP_T_building_Delete", parms, out count);
if (count > 0)
{
BindData(str);
ClientScript.RegisterStartupScript(this.GetType(),"", "<script>alert('删除成功!');</script>");
}
else
{
ClientScript.RegisterStartupScript(this.GetType(),"", "<script>alert('删除失败!');</script>");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询