程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> ASP.NET >> ASP.NET基礎 >> listview裡的button事件添加方法

listview裡的button事件添加方法

編輯:ASP.NET基礎
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);
}
}
}
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved