What is Drop down List and how to use Drop down List in ASP.NET

What is Drop down List and how to use Drop down List in ASP.NET

0 249

What is Drop down List (DDL) in ASP.NET

The Drop down List is a Standard Control in ASP.NET which is used to List many values in single list. One can select any one option out of the options in the list. Drop down List can be used in place of Radio Button. The difference is only that Radio Button acquires some space on webpage while Drop Down List acquire lesser space than Radio Button Control.

How to use Drop down list โ€“ Step by Step Guide:

  1. First Click on Toolbox List in your Visual Studio (VS) Framework and then either drag Drop down list control in your web form or double click on it.
  2. When you insert Drop down list (DDL herein after) in your web form the following coding shows in source of the web form.

<asp:DropDownList ID=”DropDownList1″ runat=”server”> </asp:DropDownList>


  1. In above coding the ID of DDL control may be DropDownList1 or it can be DropDownList2 or DropDownList3 or any thing else, because if already any DDL control with the ID DropDownList1 already exists then the smart VS Framework change the ID to DropDownList2 and if DropDownList2 exists then ID is changed to DropDownList3 end so on.
  2. Now the next step is to insert items in the DDL Control. There are 2 ways to insert the items in DDL Control.
  3. First method:

<asp:DropDownList ID=”DropDownList1″ runat=”server”>

<asp:ListItem Text=”India” Value=”0″></asp:ListItem>

<asp:ListItem Text=”Pakistan” Value=”1″></asp:ListItem>

<asp:ListItem Text=”Nepal” Value=”2″></asp:ListItem>

<asp:ListItem Text=”China” Value=”3″></asp:ListItem>

<asp:ListItem Text=”Singapore” Value=”4″></asp:ListItem>



In above coding you may see two attributes of DDL control namely Text and Value. The Text control is used to show the item in web form. The Value control is used to provide a unique value to each Text value of the control so that this item can be used in programming. There are 2 more attributes of DDL control. Consider the following line of coding.

<asp:ListItem Text=”India” Value=”0″ Enabled=”true” Selected=”True”></asp:ListItem>


The Enabled attribute is used to enable or disable the item in the list. If this attribute is set to true then the item can be selected otherwise it cannot be selected. The other attribute is selected. It has 2 values True and False. If this attribute has a value True then this Text Item will be selected by default. You may use this attribute only once with any item because at one time only one value can be selected.

6.Second method:

Just click on the design mode showing in the bottom of your web form just before to split option. Now you can see the control interface in design mode. Just right click on it and click on properties. Now in properties list you may see various options and out of these options you may see โ€œItemsโ€ option. You may see that the Collection is written in the attribute part of this option. Just click on this and you may see List Item Collector Editor pop up box. Now click on the Add button and fill the details. Finally click on OK button. Now you have done it. In this way it is coding less method to create a drop down list. When you move to coding page then you may see the same coding as above in method one. So it is your choice what method you like to use to create Drop down list. That’s it drop down list in brief. happy coding ๐Ÿ™‚


Leave a Reply