请帮我启动子转发器的ItemCommand命令。
这是我的aspx代码。
<asp:Repeater ID="rpCompany" runat="server">
<HeaderTemplate>
<div id="accordion" class="details-accordion">
</HeaderTemplate>
<ItemTemplate>
<h3 class="details-header clr">
Company Name
</h3>
<div class="col-sm-12 details-content">
<asp:Repeater ID="rpSO" runat="server">
<HeaderTemplate>
<div id="SO">
<div id="accordion2" class="details-accordion">
</HeaderTemplate>
<ItemTemplate>
<h3 class="details-header clr">
SO Number
</h3>
<div class="col-xs-12 details-content">
<div class="col-xs-12 btn-center">
<asp:Button ID="btnSave" runat="server" Text="SAVE" CssClass="btn btn-primary btn-blue-save" CommandName="SAVE" />
</div>
<div class="clr"></div>
<div class="col-xs-12">
<asp:Label ID="lblErrorSave" runat="server" Text=""></asp:Label>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</div>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
我的aspx.vb代码是
Private Sub rpSO_ItemCommand(sender As Object, e As RepeaterCommandEventArgs)
If e.CommandName = "SAVE" Then
End If
End Sub
但它没有解雇。
我已经在我的儿童中继器上添加了OnItemCommand,但它给了我一个错误。
我还在Parent Repeater中添加了AddHandler rptSO.ItemCommand, AddressOf rpSO_ItemCommand
,但仍然没有运气。
提前感谢您的帮助。
答案 0 :(得分:0)
只需在按钮中添加CommandName
,就不会在代码背后自然发生。您需要向Button添加OnCommand
或向Repeater添加OnItemCommand
。
<asp:Button ID="btnSave" runat="server" OnCommand="btnSave_Command" Text="SAVE" CommandName="SAVE" />
Protected Sub btnSave_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
//code
End Sub
<asp:Repeater ID="rpSO" runat="server" OnItemCommand="rpSO_ItemCommand">
Protected Sub rpSO_ItemCommand(ByVal source As Object, ByVal e As RepeaterCommandEventArgs)
//code
End Sub
答案 1 :(得分:0)
解决方案:
将AddHandler
放入创建的Repeater项目中。
此链接可帮助我解决问题。
https://www.mindstick.com/Forum/45/itemcommand-event-in-nested-repeater-and-listview