Button event addition method in listview

Source: Internet
Author: User

1.
Copy codeThe Code is as follows:
<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 ('Are you sure you want to delete this message? '); "Onclick =" lb_delete_Click "Text =" delete "> </asp: LinkButton>
</Td>/tr>
</ItemTemplate>
</Asp: ListView>

2.
Copy codeThe Code is as follows:
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 ('deleted successfully! '); ", True );
Datebind ();
}
Else
{
This. ClientScript. RegisterStartupScript (this. GetType (), this. Title, "alert ('deletion failed! '); ", True );
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.