We help IT Professionals succeed at work.

dynamic populate drop down menu asp.net/C#

elliottbenzle
on
Hi, I have a dynamically populated drop down menu which is working fine. I would like however to add a non dynamic item at the top of the list that says "SELECT EMPLOYEE". This should not interfere with the dynamic content. Coud someone take a look and explain to me how this is done? Thanks.

My code for the list:
<asp:DropDownList ID="employeeList" runat="server" AutoPostBack="true" onselectedindexchanged="employeeList_SelectedIndexChanged"></asp:DropDownList>

My code for dynamically populating the list.
private void LoadEmployeesList();
{
SqlConnection conn;
SqlCommand comm;
SqlDataReader reader;
string connectionstring = configurationManager.ConnectionStrings["Dorknozzle"].ConnectionString;
conn = new SqlConnection(connectionString);
comm = new SqlCommand("SELECT EmployeeID, Name FROM Employees", conn);
try
{
conn.Open();
reader = comm.ExecuteReader();
EmployeeList.Datasource = reader;
EmployeeList.DataValueField = "EmployeeID";
EmployeeList.DataTextField = "Name";
employeeList.DataBind();
reader.Close();
}
catch
{
dbErrorLabel.Text = "Problem populating list.";
}
finally
{
conn.Close();
}
}

Thanks for any help.
Comment
Watch Question

After DataBind() add below code:

employeeList.Items.Insert(0, new ListItem("SELECT EMPLOYEE", "-1"));

Author

Commented:
Great, Thank you.
Welcome :-)