views:

44

answers:

2

I have a dropdown list which is in updatepanel. I have to fill that dropdown on a client event through javascript which calls __dopostback of the updatepanel and calls its load event.

Problem is that when i submit the form updatepanel_Load event also execute again and it again reset the DropDownLIst which causes the loss of selectedValue in Dropdown.

<asp:UpdatePanel  ID="UpdatePanel3" runat="server" OnLoad="UpdatePanel3_Load" UpdateMode="Conditional">

   <ContentTemplate>


       <asp:DropDownList ID="ddlItems" runat="server" CssClass="dropdown">                  
       </asp:DropDownList>                 

   </ContentTemplate>
</asp:UpdatePanel>

On page Load this dropdown is Empty .... no funtion to fill it.

Now the problem is when ever I Fill the Dropdown throught Load of UPatepanel, that UPdatepanel Load event also execute when I submit my page. Actually the solution of javascript is due to a table and on Selection of the table row item it Fills the DropDownList from __dopostback of my updatepanel.

I have button which opens a popup window and that popup window contains a table, when client select some item from that table and close that popup window then I fill my dropdown (in parent or opener page through Ajax, Updatepanel's Load) as further selction option. so dropdown databind is dependent on that tables input.

+2  A: 

What about your page load? If you are loading your ddl in your page load, you load items on every click. Use;

If Not Page.IsPostBack then
NetSide
no .... its not on pageLoad .... only on load of updatepanel.
Azhar
A: 

I have to handle it with javascript. So I save the selected value on DropDownList on onchange event in Hidden field and save from that hidden field because at save event dropdown gets reset and lost the selected item.

Because I observed that when I clicked save button the callback events which used also called before button click event. So as my case it resets the Dropdown.

Azhar