首页 > 编程 > .NET > 正文

listview里的button事件添加方法

2024-07-10 13:23:20
字体:
来源:转载
供稿:网友
1.

复制代码 代码如下:


<asp:ListView runat="server" >
<LayoutTemplate>
<div>
<table border=0 cellpadding=0 cellspacing=0>
<asp:PlaceHolder id=itemPlaceholder runat=server/>
</table>
<div></div>
</div>
</LayoutTemplate>
<ItemTemplate>
<tr><td>
<asp:LinkButton runat="server" CommandArgument='<%#Eval("ItemCode")%>' OnClientClick="return confirm('确定删除此条信息?');" 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);
}
}
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表