Sunday, October 23, 2011

How to use simple CascadingDropDown with Database without ASP.NET AJAX and Webservice


In this tutorial we are performing CascadingDropDown without ASP.NET AJAX and Webservice. We are retrieving values of country and city from Database. Here we are loading country name in first DropDownList on Page_Load event and on selecting desired name of country in first DropDownList, onselectedindexchanged event get fired and second DropDownList get Loaded with city names corresponding to selected country name in first DropDownList.

Step 1: Create two Tables in your Database.mdf  as i have created here with name city and country.

country Table:



city Table:

Step 2:
Defaut.aspx page code
This code will also work , If we will not use UpdatePanel but UpdatePanel makes it work like Ajax.



Step 3:
Default.aspx.cs page code
(Click on Image to enlarge it)
Populating Values in First DropDownList

Populating Values in Second DropDownList

View in Browser:

No comments:

Popular Posts