Javatpoint Logo
Javatpoint Logo

ASP.NET DropDownList

The DropDownList is a web server control which is used to create an HTML Select component. It allows us to select an option from the dropdown list. It can contain any number of items

ASP.NET provides a tag to create DropDownList for web application. The following is the Syntax of DropDownList tag.

ASP.NET DropDownList Example

We are creating DropDownList by using Visual Studio 2017. This example includes the following steps.

Create a Web Form

Add a new form by specifying its name.

ASP Net Dropdown list 1

Initially, it is an empty form. Now, we will add a new DropDownList by dragging it from the toolbox.

ASP Net Dropdown list 2

After dragging, our web form looks like the below.

ASP Net Dropdown list 3

Now, to add items to the list, visual studio provides Items property where we can add items. The property window looks like this.

ASP Net Dropdown list 4

Click on the items (collection) and it will pop up a new window as given below. Initially, it does not have any item. It provides add button to add new items to the list.

ASP Net Dropdown list 5

Adding item to the DropDownList, by providing values to the Text and Value properties.

ASP Net Dropdown list 6

We have added more items to it and now, it looks like the following.

ASP Net Dropdown list 7

After clicking OK,


DropDownListExample.aspx

// DropDownListExample.aspx.cs

Output:

ASP Net Dropdown list 8

At server side, selected city is fetched and display to the user.

ASP Net Dropdown list 9
Next TopicASP.NET DataList





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA