Take the 2-minute tour ×

my dropdownlist is populated from the database as in:

DataTable dt = GetData(); ddlMylist.DataSource = dt; ddlMylist.DataBind();

Now dt contains the data, and I wish to add "Select" word to the top of the list when the selection is blank. It seems as there is no option other than add it to the dt (DataTable object)....but it seems wrong somehow.

What are other options. It's doesn't have to be the word "Select" it can be just an empty space...Currently, upon page load I can see the first data item in the list which is all good and dandy, but I have 3 drop downs that are co-dependent, and I want the user to explicitly make a selection which will trigger other drop downs to populate accordingly.

share|improve this question

4 Answers 4

up vote 5 down vote accepted


ddlMylist.Items.Insert(0, new ListItem([key], [text]));
ddlMylist.SelectedIndex = 0;

You do this after you databind to your source.

share|improve this answer
for example ... new ListItem( String.Empty, "--Select--") –  MikeW Dec 14 '09 at 23:23
or just ddlMyList.Items.Insert(0, new ListItem()); –  B Woods May 9 '12 at 14:57

Your dropdownlist markup should look like this:

<asp:DropDownList ID="ddlMylist" runat="server" AppendDataBoundItems="true">
    <asp:ListItem Text="-Select-" Value="" />

Note the AppendDataBoundItems attribute.

share|improve this answer
Turns out that now, every time the drop down is rebound, the items get appended, which is not what i want. i just want to add "Select" to the top of the list, that's all. This list is dependent on other selection, so its contents should change, not get appended. It looks like it's either appending ALL THE TIME or NEVER with drop down list. very frustrating when such a minute task requires so much work. –  sarsnake Dec 18 '09 at 1:11
You're doing something else wrong with viewstate then to keep these items around. –  Joel Coehoorn Dec 18 '09 at 1:49
no, according to Scott Guthrie's blog: Specifically it is a property called "AppendDataBoundItems", and it controls whether the items within an existing list are replaced or appended-to when the control is databound (with ASP.NET 1.1 the items were always replaced). weblogs.asp.net/scottgu/archive/2006/01/29/436804.aspx something to keep in mind –  sarsnake Dec 18 '09 at 18:04
so in other words if you say AppendDataBoundItems - true, the items will always be appended when the list is databound, which is exactly what's happening. Hence I re-opened this question. –  sarsnake Dec 18 '09 at 18:05
Ah, but each postback works with a new instance of the control. Any previous data binding results should be lost. So you're doing something wrong to make these persist in viewstate, even though they shouldn't. –  Joel Coehoorn Dec 18 '09 at 18:27

Try this one:

ddlMylist.Items.Insert(0, "Select");
share|improve this answer


DDL.Text = string.Empty;


I know this works when I'm manually adding items but I'm not sure if it will when a DataSource is bound.

share|improve this answer
doesn't work. Please note that I am using DropDownList not combo box control. After binding this is ignored and before binding, I get an error saying that empty space is not in the data list (which is true) –  sarsnake Dec 14 '09 at 23:11
Ya I didn't see that at first. Sorry to lead you down the wrong path. –  Cory Charlton Dec 14 '09 at 23:33
no worries:) i don't think it's the control actually - it's probably like you said because I use DataBind() –  sarsnake Dec 15 '09 at 17:47

Your Answer


