Tuesday, June 17, 2008

Default Item for the DropDownList

You can bind C# dropdownlist to datasource and then assign the default value to it using following syntax. By default the 0th item is selected but you can specify it explicitly if you want to select item at different location.

dropDownList.Items.Insert(0,"Please Select"); // Inserts at the first location
dropDownList.Items[0].Selected = true; // First location is selected

No comments: