下面是我的代码,任何人都可以指导我在转发器控件上调用 html 按钮。
标记:
<asp:Repeater ID="rptList" runat="server" onitemcommand="rptList_ItemCommand1">
<HeaderTemplate>
<table id="tbllist">
<tr>
<th>Qty</th>
<th width="100%" align="left">Item</th>
<th></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="center"><%# Eval("Quantity")%></td>
<td align="left"><%# Eval("ItemName")%></td>
<td align="center"><input id="Button1" runat="server" commandname="btnAdd" type="button" value="Addtocart" /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
.CS 文件代码:
protected void rptList_ItemCommand1(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
if (e.CommandName == "btnAdd")
{
Response.Write("hello,I am a button.");
}
}