How to Add Items in DropDownList Programmatically

1.File->New->Click Website


2.(left side select visual c#) ASP.NET Web Site->ok

3.Now You will see a Default.aspx page. To create your own page->click on dropdown list below Edit->click Add new item->

4.Select Web Form(you change your page name)->click Add

5.Click Design->From ToolBox Drag and Drop a Label to Design window->Right click on  label->select properties->(look for text property) change text property from label to "Select University".

 6. Toolbox->Drag and drop a DropDownList to Design window(or Double click on DropDownList) Beside label1.
 Your window Should look similar to this

7.Right Click DropDownList->Select Properties->Click Events(Shown Horizontal arrow)->Double Click on Init Event(or You can also click on Load Event).

8.Now Write This Code .


9.Click F5->Ok

1 comment: