listview里的button事件添加方法
更新時(shí)間:2012年12月28日 09:01:54 作者:
搞了很長(zhǎng)時(shí)間了,如何在listview button上添加事件監(jiān)聽,一直是網(wǎng)友們比較在意的,本文將為您解答此疑惑,需要了解的朋友可以參考下
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);
}
}
}
復(fù)制代碼 代碼如下:
<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.
復(fù)制代碼 代碼如下:
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);
}
}
}
相關(guān)文章
Linq to SQL Delete時(shí)遇到問題的解決方法
在Linq to SQL中要?jiǎng)h除一行記錄,官方的例子教我這樣做2008-03-03
告別ADO.NET實(shí)現(xiàn)應(yīng)用系統(tǒng)無縫切換的煩惱(總結(jié)篇)
說起ADO.NET,就扯上了數(shù)據(jù)庫訪問類庫了,現(xiàn)在的每個(gè)項(xiàng)目的數(shù)據(jù)庫訪問類應(yīng)該說都很強(qiáng)的了,經(jīng)常就聽到說我的我們的數(shù)據(jù)庫訪問類怎么怎么強(qiáng)大而且支持多數(shù)據(jù)庫,現(xiàn)在的大家做的項(xiàng)目里用的數(shù)據(jù)庫訪問類庫我想也都是支持多數(shù)據(jù)庫吧,支持到什么程度我就不知道了2009-11-11
.NET+JS對(duì)用戶輸入內(nèi)容進(jìn)行字?jǐn)?shù)提示功能的實(shí)例代碼
.NET+JS對(duì)用戶輸入內(nèi)容進(jìn)行字?jǐn)?shù)提示功能的實(shí)例代碼,需要的朋友可以參考一下2013-06-06
一個(gè)簡(jiǎn)單的ASP.NET Forms 身份認(rèn)證的實(shí)例方法
當(dāng)訪問默認(rèn)首頁default.aspx時(shí),會(huì)自動(dòng)跳轉(zhuǎn)到login.aspx頁面上請(qǐng)求登錄,隨便輸入用戶名和密碼,點(diǎn)擊“登錄”按鈕,會(huì)回到首頁,并顯示當(dāng)前登錄的用戶名。2013-07-07
asp.net下Repeater使用 AspNetPager分頁控件
AspNetPager針對(duì)ASP.NET分頁控件的不足,提出了與眾不同的解決asp.net中分頁問題的方案2010-03-03
asp.net微信開發(fā)(已關(guān)注用戶管理)
這篇文章主要介紹了asp.net微信開發(fā)中有關(guān)已關(guān)注用戶管理的相關(guān)內(nèi)容,需要的朋友可以參考下2015-11-11
ASP與ASP.NET互通COOKIES的一點(diǎn)經(jīng)驗(yàn)
ASP與ASP.NET互通COOKIES的一點(diǎn)經(jīng)驗(yàn)...2006-09-09
C#基礎(chǔ)之?dāng)?shù)據(jù)類型轉(zhuǎn)換
簡(jiǎn)單認(rèn)識(shí)顯式轉(zhuǎn)換和隱式轉(zhuǎn)換 我們就從下面這段代碼段開始吧2013-02-02

