Dropdownlist Default Text

Dropdownlist Default Text

When a dropdownlist is binded to a datasource, the list contains the values from the datasource. In this case if we want to set the default initial text for the dropdownlist then use the following code.

 ListItem item = new ListItem();
 item.Value = “0″;
 item.Text = “Select Product”;
 dropdownlist1.Items.Insert(0, item);

the above code will add the list item as the initial default text for the dropdown list where rest of the items are binded to a datasource. 

 

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.