Tuesday, August 19, 2008
DropDownList.Items.Add method allows you to add new ListItem into the DropDownList. This item will be added as the last item of the DropDownList.
dropDownList.Items.Add(new ListItem("Default Panel", "0"));
DropDownList.Items.Insert method allows you to specify the index of the item within the DropDownList where you want to insert the ListItem.
dropDownList.Items.Insert(0, new ListItem("Default Panel", "0"));
Here Default Value will be added as the first item in the DropDown.
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.