本文介绍了在listview itemteplate中访问按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码如下 -
< asp:ListView ID =productListrunat =serverDataKeyNames =ProductIDGroupItemCount =4 ItemType =BiggMart.Models.ProductSelectMethod =GetProductsOnItemCommand =productList_ItemCommand>
My code is as follows-
<asp:ListView ID="productList" runat="server" DataKeyNames="ProductID" GroupItemCount="4" ItemType="BiggMart.Models.Product" SelectMethod="GetProducts" OnItemCommand="productList_ItemCommand">
<ItemTemplate>
<td runat="server">
<ul>
<li class="first">
<asp:Button runat="server" text= "Add" CssClass="button" OnClick="Unnamed_Click">
</asp:Button>
我想在后面的代码中访问此按钮点击事件。我该怎么办?
I want to access this button click event in code behind. How can I do it?
推荐答案
protected void Unnamed_Click(object sender, EventArgs e)
{
//Your Code
}
您可以绑定按钮的CommandArgument属性并在代码中使用它。
You can bind CommandArgument property of button and use it in code.
这篇关于在listview itemteplate中访问按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!