The essence of your question, I believe, is as follows:
"when I select any value from the drop-down list, I load some data from the database, which depend on this selected value. Before the page with the changes is changed, I will have a problem."
There are many ways to achieve this, but some restructuring may be required for its desired effect. A relatively simple way to do this:
(1) Rearrange your page as follows:
<asp:DropDownList ID="ddList" CssClass="dropdown" Style="width: 200px !important;" runat="server" AutoPostBack="false"> </asp:DropDownList> <asp:UpdatePanel ID="OuterUpdatePanel" runat="server"> <ContentTemplate> </ContentTemplate> </asp:UpdatePanel>
(2) Add a script as follows:
<script type="text/javascript"> function handleDDLChange() { __doPostBack($('div[id$="OuterUpdatePanel"]').attr('id'), 'ddlList_Changed_Or_Anything_Else_You_Might_Want_To_Key_Off_Of'); } $('input[id$="ddlList"]').change( handleDDLChange ); </script>
This is an older approach, but it should solve your problem.
EDIT: The following is a description of the non-jQuery approach, with the idea above being a little more specific:
ASCX:
<asp:ScriptManager runat="server" /> <asp:DropDownList ID="ddlList" runat="server" onchange="handleDDLChange()"> <asp:ListItem Text="text1" /> <asp:ListItem Text="text2" /> </asp:DropDownList> <script type="text/javascript"> function handleDDLChange() { __doPostBack("<%= ddlList.ClientID %>", "ddlList_Changed_Or_Anything_Else_You_Might_Want_To_Key_Off_Of"); } </script> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Literal ID="litTest" runat="server" /> </ContentTemplate> </asp:UpdatePanel>
Code-Behind:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { litTest.Text = "No postback"; } else if (Request["__EVENTARGUMENT"] == "ddlList_Changed_Or_Anything_Else_You_Might_Want_To_Key_Off_Of") { litTest.Text = string.Format("Dropdown changed: {0}", ddlList.Text); } else { litTest.Text = "Postback for some other reason... :("; } }