listview里的button事件添加方法
程序员文章站
2024-03-04 20:44:00
1. 复制代码 代码如下:
1.
<asp:listview id="lvbalance" runat="server" >
<layouttemplate>
<div id="listdiv" style="width:100%;overflow-y:auto;">
<table border=0 cellpadding=0 cellspacing=0 style="float:left;table-layout:fixed;" class="datagrid-body easydatagrid">
<asp:placeholder id=itemplaceholder runat=server/>
</table>
<div id="div999" style='display: none; width: 200px;' class="div2"></div>
</div>
</layouttemplate>
<itemtemplate>
<tr><td>
<asp:linkbutton id="lb_delete" runat="server" commandargument='<%#eval("itemcode")%>' onclientclick="return confirm('确定删除此条信息?');" onclick="lb_delete_click" text="删除"></asp:linkbutton>
<</td>/tr>
</itemtemplate>
</asp:listview>
2.
protected void lb_delete_click(object sender, eventargs e)
{
linkbutton lbdelete = (linkbutton)sender;
bllaccount bll_updatebalance = new bllaccount();
if (hd_vehiclecode.value != "" && lbdelete.commandargument != "")
{
if (bll_updatebalance.deletebalance(hd_vehiclecode.value, lbdelete.commandargument) == true)
{
this.clientscript.registerstartupscript(this.gettype(), this.title, "alert('删除成功!');", true);
datebind();
}
else
{
this.clientscript.registerstartupscript(this.gettype(), this.title, "alert('删除失败!');", true);
}
}
}
复制代码 代码如下:
<asp:listview id="lvbalance" runat="server" >
<layouttemplate>
<div id="listdiv" style="width:100%;overflow-y:auto;">
<table border=0 cellpadding=0 cellspacing=0 style="float:left;table-layout:fixed;" class="datagrid-body easydatagrid">
<asp:placeholder id=itemplaceholder runat=server/>
</table>
<div id="div999" style='display: none; width: 200px;' class="div2"></div>
</div>
</layouttemplate>
<itemtemplate>
<tr><td>
<asp:linkbutton id="lb_delete" runat="server" commandargument='<%#eval("itemcode")%>' onclientclick="return confirm('确定删除此条信息?');" onclick="lb_delete_click" text="删除"></asp:linkbutton>
<</td>/tr>
</itemtemplate>
</asp:listview>
2.
复制代码 代码如下:
protected void lb_delete_click(object sender, eventargs e)
{
linkbutton lbdelete = (linkbutton)sender;
bllaccount bll_updatebalance = new bllaccount();
if (hd_vehiclecode.value != "" && lbdelete.commandargument != "")
{
if (bll_updatebalance.deletebalance(hd_vehiclecode.value, lbdelete.commandargument) == true)
{
this.clientscript.registerstartupscript(this.gettype(), this.title, "alert('删除成功!');", true);
datebind();
}
else
{
this.clientscript.registerstartupscript(this.gettype(), this.title, "alert('删除失败!');", true);
}
}
}
上一篇: 史上最全面的Spring Boot配置文件深入讲解
下一篇: 微信 开发生成带参数的二维码的实例