hussainAbid
asked on
DropDownList Inside a Repeater ASP.NET Not firing IndexChanged Event
Hi everybody, (USING ASP.NET & C#)
I am having a repeater inside an update panel and there is one DropDownList inside repeater. I have set AutoPostBackTrue for that Repeater and have defined event IndexChanged.
all the instances of drop down list always have list with values 0,1,2,3,4,5 and here is my problem.
Let say there are two rows in repater hence two drop downs X and Y. And I change value of X to 1 (It fires event and does what it should), then I change Y to be 2 (It does what it should i.e. fires indexChanged event) I move Y = 0 (setting back to 0 still fires indexChanged) but when I set X=0 (i.e. all ddl back to original values so this last change does not fire DDL IndexChanged event) and this last move is a problem for me.
Furthermore everytime i am changing something in one dropdownlist it is firing IndexChangedEvent as many times as there dropDownLists.
Please help me to solve this issue. I have played hours with it. And if this is not the right way to do it then suggest me a better way to fire an event everytime something is changed on DDLS inside repeater. Many thanks in Advanced.
I am having a repeater inside an update panel and there is one DropDownList inside repeater. I have set AutoPostBackTrue for that Repeater and have defined event IndexChanged.
all the instances of drop down list always have list with values 0,1,2,3,4,5 and here is my problem.
Let say there are two rows in repater hence two drop downs X and Y. And I change value of X to 1 (It fires event and does what it should), then I change Y to be 2 (It does what it should i.e. fires indexChanged event) I move Y = 0 (setting back to 0 still fires indexChanged) but when I set X=0 (i.e. all ddl back to original values so this last change does not fire DDL IndexChanged event) and this last move is a problem for me.
Furthermore everytime i am changing something in one dropdownlist it is firing IndexChangedEvent as many times as there dropDownLists.
Please help me to solve this issue. I have played hours with it. And if this is not the right way to do it then suggest me a better way to fire an event everytime something is changed on DDLS inside repeater. Many thanks in Advanced.
<asp:repeater ID="rptSizes" enableviewstate="false" runat="server" onitemdatabound="rptSizes_ItemDataBound" >
<HeaderTemplate>
<table cellpadding="2" cellspacing="3">
<tr>
<th>
<asp:literal id="ltrSizeColumHeading" text="Size" runat="server"></asp:literal>
</th>
<th>
<asp:literal id="ltrNumberOfProducts" text="Antal" runat="server"></asp:literal>
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:literal id="ltrProductSizeName" runat="server"></asp:literal>
</td>
<td>
<asp:dropdownlist id="ddlQuantity" runat="server" cssclass="quantityTextBox" runat="server" AutoPostBack="true" onselectedindexchanged="ddlQuantity_SelectedIndexChanged">
<asp:listitem text="0" value="0"></asp:listitem>
<asp:listitem text="1" value="1"></asp:listitem>
<asp:listitem text="2" value="2"></asp:listitem>
<asp:listitem text="3" value="3"></asp:listitem>
<asp:listitem text="4" value="4"></asp:listitem>
<asp:listitem text="5" value="5"></asp:listitem>
</asp:dropdownlist>
<asp:literal id="ltrUnit" text="Stk." runat="server"></asp:literal>
</td>
</tr>
<asp:hiddenfield id="hidBonusProductID" runat="server" />
</ItemTemplate>
<footertemplate>
</table>
</footertemplate>
</asp:repeater>
protected void ddlQuantity_SelectedIndexChanged(object sender, EventArgs e) {
//DoSomething
}
In the updatePanel, write trigger also for dropdownlist
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for reply Raj,
Can not write trigger for update panel because Update panel is outer bounded to a div that then has a control called ProductList and then comes nested control Product and that is where this repater is placed. Anymore sugessions...
Can not write trigger for update panel because Update panel is outer bounded to a div that then has a control called ProductList and then comes nested control Product and that is where this repater is placed. Anymore sugessions...
ASKER
Thanks Mr Shah, It worked but can you please explain me How would it effect this behaviour of DropDownList. I will highky appreciate it.
ASKER
Thanks Mr Shah, It worked but can you please explain me How would it effect this behaviour of DropDownList. I will highky appreciate it.
Hi,
its affecting because when your dropdown selected index change event fires, the postback of the page occurs and so the page_load event fires first whih causes your repeater and dropdown binding again,so your dropdown value changes to the default one.
its affecting because when your dropdown selected index change event fires, the postback of the page occurs and so the page_load event fires first whih causes your repeater and dropdown binding again,so your dropdown value changes to the default one.