martmartius
martmartius

Reputation: 38

ASP.Net 4.0 OnSelectedIndexChanged event is not firing in ItemTemplate (Repeater)

Why I cant access OnSelectedItemChanged event? I already add AutoPostBack="true" in the textbox. Already tried to debug but still not firing.

Below are the sample codes:

<asp:Repeater runat="server">
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Key") %>'></asp:Label><br />
            <asp:CheckBoxList AutoPostBack="True" ID="CategoryAttributes"
                runat="server"
                DataSource='<%# DataBinder.Eval(Container.DataItem, "Value") %>'
                DataTextField="Text"
                DataValueField="Value"
                OnSelectedIndexChanged="OnSelectedIndexChanged">
            </asp:CheckBoxList>
        </ItemTemplate>
    </asp:Repeater>

Upvotes: 1

Views: 310

Answers (1)

Constanta
Constanta

Reputation: 399

because the textbox is inside Repeater you need to use RepeaterItemEvent for example

in your markup OnItemCommand="Rpt_ItemCommand"

in your codebehind

Protected Sub Rpt_ItemCommand(ByVal sender As Object, ByVal e As RepeaterCommandEventArgs)
'where your code goes
End Sub

Upvotes: 1

Related Questions