You can have the control throw an event which your page (with the repeater) can listen for. Any information you need for the event can be provided when initializing each control.
Repeater ItemCommand does not fire when clicking a button inside composite control
-
07-12-2021 - |
سؤال
I have a Repeater
containing nested custom CompositeControl
controls in the following way:
Wrapper
Head
Body
<asp:UpdatePanel ID="noteArea" UpdateMode="Conditional" ChildrenAsTriggers="false" runat="server" >
<ContentTemplate>
<asp:Repeater ID="noteRepeater" runat="server" EnableViewState="true" OnItemDataBound="noteRepeater_ItemDataBound" OnItemCommand="noteRepeater_ItemCommand">
<ItemTemplate>
<asp:Button runat="server" CommandName="edit" ID="testButton" />
<easit:NoteControl ID="noteControl" runat="server" />
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
Head
control contains two Buttons
. When I click on either of them, the ItemCommand
event of Repeater
doesn't get invoked. If I move the buttons right to ItemTemplate
, it works. But I need to keep them where they are.
What is the correct way to bubble them up the control hierarchy?
المحلول
نصائح أخرى
These controls are outside the ItemTemplate .. so they really can't trigger an ItemCommand.
An ItemCommand has specific attributes that will not be available to your buttons if they are outside the ItemTemplate (ItemIndex for instance, to determine the index of the clicked item)
لا تنتمي إلى StackOverflow