Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 How to keep SELECT in DROPDOWN LIST in ASP.NET(Visual Studio 2005)
Posted by sowjanya on  1/19/2010 6:19:51 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
How to keep SELECT in DROPDOWN in ASP.NET.

I wrote SELECT in DROPDOWN properties of collections and I binded data to DROPDOWN from database.
I wrote the code and i am getting the output also but the problem is i am not able to see the SELECT in DROPDOWN in the output.

Post Your Reply Post New Question

 Viewer's Reply
Insert Select Option in Asp.Net DropdownList control
Answered By Moderator1 on 1/19/2010 7:41:40 PM

If you add Select option before you bind the dropdown, it will not appear in the run-time. So you need to do the other way like below,

1. Bind your dropdown list with data from database
2. Insert the Select option into the option list.

Below is the sample code,
DropDownList.DataSource = yourDataTable;
DropDownList.Items.Insert(0, new ListItem("Select", "Select"));
How to keep SELECT in DROPDOWN LIST in ASP.NET(Visual Studio 2005)
Answered By sowjanya on 1/20/2010 11:54:25 PM
Thanks for your answer.That code is very helpful to me.
Very Nice Code.
Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
The Art & Science of JavaScript - Free 100 Page Preview!
Web Application Security — How to Minimize Prevalent Risk of Attacks
Programmers Heaven C# School Book - Free 338 Page eBook