ASP.NET - How to Avoid Page Load for binded Dropdownlists?

Asked By Sai M on 18-Apr-13 03:00 AM
Country:</label><asp:DropDownList ID="cmbCountry" runat="server" OnSelectedIndexChanged="cmbCountry_SelectedIndexChanged"
                AutoPostBack="true" AppendDataBoundItems="True">
                <asp:ListItem Value="0">Select</asp:ListItem>
              </asp:DropDownList>
 
 State:</label><asp:DropDownList ID="cmbState" runat="server" OnSelectedIndexChanged="cmbState_SelectedIndexChanged"
                AutoPostBack="true" AppendDataBoundItems="True">
                <asp:ListItem Value="0">Select</asp:ListItem>
              </asp:DropDownList>
 
 <asp:DropDownList ID="cmbCity" runat="server" AppendDataBoundItems="True" ClientIDMode="Static">
              <asp:ListItem Value="0">Select</asp:ListItem>
            </asp:DropDownList>
 
 
 
State gets dsiplayed on autopostback of Countries vice versa...How to avoid autopostback..its effecting total page when the country is selected...
Danasegarane Arunachalam replied to Sai M on 18-Apr-13 12:56 PM
Either place this controls inside Ajax, for fill the other values using HttpRequest

And for the second method you can refer the example posted here : http://jquerybyexample.blogspot.com/2012/04/how-to-populate-aspnet-dropdownlist.html
Sai M replied to Danasegarane Arunachalam on 19-Apr-13 02:35 AM
Alreay the dropdownlists are being binded from database..When ever iam selecting Country  the page is reloaded and then the states get binded..I need Jquery method to avoid autopostback that is happening while selecting the dropdown lists using Jquery...Here the 3 drop downlists having the property Autopost Back as true..SO how to avoid pageload  while autopost back is true for a asp Dropdownlists using Jquery..Binding Porcess is done through C# code.
Danasegarane Arunachalam replied to Sai M on 21-Apr-13 05:58 AM
Set the AutoPostback property to false to dropdown. On the Client side handle the onchange event. In that event you need to call the Jquery method that calls the server side from same page or some other page that returns value to be binded to the other dropdown. Then bind these valus to the dropdown.

Have a look at this example which explains the onchange method

http://davidejones.com/blog/55-jquery-populate-dropdown-menus/
Danasegarane Arunachalam replied to Sai M on 21-Apr-13 05:59 AM
And this is the jquery document for handling the onchange event .

http://api.jquery.com/change/