listview里的button事件

本文详细介绍了如何使用ASP.NET ListView控件实现数据分页功能,并结合LinkButton实现了单条记录的删除操作。通过事件处理,确保用户在删除前确认操作,同时提供了客户端的提示信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

转载于:https://www.cnblogs.com/wuchao/archive/2012/10/29/2745044.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值