I am putting a DropDownList with AutoPostBack inside a Repeater.
(The ListItems are populated on the repeater’s ItemDataBound)
<asp:Repeater ID="rptWishlist" OnItemCommand="rptWishlist_ItemCommand" onItemDataBound="rptWishlist_ItemDataBound" runat="server">
<ItemTemplate>
...
<asp:DropDownList ID="ddlSize" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlSize_SelectedIndexChanged" />
...
-
Firstly, this function was not even fired on post back
protected void ddlSize_SelectedIndexChanged(object sender, EventArgs e)
{
//This function is never called
} -
How would I then get the DataItem after I get it working?
Am I doing this the wrong way?
Thank you in advance.
To register the dropdownlist for postback, add the following code:
And in your aspx file, add this to your repeater markup:
Then, in your ddlSize_SelectedIndexChanged function, you can access the parent control like this:
Hope this helps.