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.

<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
      }

Open in new window

hussainAbidAsked:
Who is Participating?
 
krunal_shahConnect With a Mentor Commented:
bind repeater inside ,
if(!Page.IsPostBack)
{
}
0
 
rajvjaCommented:
In the updatePanel, write trigger also for dropdownlist
0
 
hussainAbidAuthor Commented:
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...
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
hussainAbidAuthor Commented:
Thanks Mr Shah, It worked but can you please explain me How would it effect this behaviour of DropDownList. I will highky appreciate it.
0
 
hussainAbidAuthor Commented:
Thanks Mr Shah, It worked but can you please explain me How would it effect this behaviour of DropDownList. I will highky appreciate it.
0
 
krunal_shahCommented:
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.
0
All Courses

From novice to tech pro — start learning today.