我有一个转发器,里面有一个链接按钮,转发器绑定到 OnItemCommand 但事件没有触发这里是我的代码:
<asp:Repeater ID="rptList" runat="server" OnItemDataBound="rpt_OnItemDataBound" OnItemCommand="rptList_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="lbName" Text='<%# Eval("Name") %>' runat="server"
CommandArgument='<%# Eval("ID").ToString() %>' CommandName="NameClick">
</asp:LinkButton><br />
<asp:Label ID="lblCreateDate" runat="server" Text='<%# Eval("CreateDate") %>' /><br />
<br />
</ItemTemplate>
</asp:Repeater>
这是后面的代码:
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "NameClick":
Guid id = (Guid)e.CommandArgument;
//do something
break;
default:
break;
}
}