欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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);
}
}
}