Total Page Preview: 000000005426
What is cascading dropdownlist in ASP.NET in English and Hindi
Cascading dropdownlist in ASP.NET in English
A cascading dropdownlist is a series of dropdownlists where the options in each dropdownlist are filtered based on the selected option in the previous dropdownlist. This is a common feature in web applications where the user needs to select from a large set of options, and the options are grouped in a hierarchy.
Here's a detailed example of how to implement cascading dropdownlists in ASP.NET:
Let's say we have three dropdownlists: Country, State, and City. The user first selects a country, which then filters the available states, and finally the selected state filters the available cities.
1-First, create a database with tables for Country, State, and City, with appropriate relationships between them.
2-In your ASP.NET page, add three dropdownlists, one for each level of the hierarchy: Country, State, and City.
3-Populate the Country dropdownlist with the list of available countries from the database.
4-Set up an event handler for the Country dropdownlist, which will be called when the user selects a country. In this event handler, populate the State dropdownlist with the list of available states for the selected country.
5-Set up an event handler for the State dropdownlist, which will be called when the user selects a state. In this event handler, populate the City dropdownlist with the list of available cities for the selected state.
6-Finally, add a default option to each dropdownlist, and set the AutoPostBack property to true for each dropdownlist so that the event handlers will be called when the user selects an option.
That's it! With these steps, you have implemented cascading dropdownlists in your ASP.NET application. When the user selects a country, the State dropdownlist is populated with the available states for that country, and when the user selects a state, the City dropdownlist is populated with the available cities for that state.
Cascading dropdownlist in ASP.NET in Hindi
Cascading DropdownList asp.net mai ek aisa feature hai jisme ek series of DropdownList hote hai jinme har DropdownList ke options previous DropdownList mai select kiye gaye option ke basis par filter kiye jaate hai. Ye web applications mai ek common feature hai jahan par user ko ek bada set of options se choose karna hota hai aur options hierarchy mai group kiye jaate hai.
Yahan mai asp.net mai Cascading DropdownList ka ek example detail mai explain kar raha hu:
Mana ki hamare pass teen DropdownList hai: Country, State, and City. User pahle ek country select karta hai, phir us selected country ke basis par available states filter hote hai, aur ant me selected state ke basis par available cities filter hote hai.
1-Sabse pahle, Country, State, and City ke tables ke saath ek database create kijiye, aur unke beech appropriate relationships set kijiye.
2-Apne ASP.NET page mai teen DropdownList add kijiye, har hierarchy level ke liye ek: Country, State, and City.
3-Country DropdownList ko available countries ki list se populate kijiye, jo database se retrieve karni hogi.
4-Country DropdownList ke liye ek event handler set up kijiye, jo tab call hoga jab user ek country select karega. Is event handler mai, State DropdownList ko selected country ke available states ki list se populate karein.
5-State DropdownList ke liye ek event handler set up kijiye, jo tab call hoga jab user ek state select karega. Is event handler mai, City DropdownList ko selected state ke available cities ki list se populate karein.
6-Ant me, har DropdownList mai ek default option add karein, aur har DropdownList ke AutoPostBack property ko true set karein taaki jab user ek option select kare, tab event handlers call ho sakein.
Thank You
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com