11
Answers

Something wrong with C# dropdown list

timothy.farrell

timothy.farrell

20y
1.8k
1
I can't seem to get my dropdown list to populate. Webform: Code Behind: void ddl_DataBind() { SqlConnection SqlConn = new SqlConnection("server=c099450d01;uid=sa;pwd=;database=Tools"); SqlCommand SqlCmd = new SqlCommand("SELECT UID, LastName, FirstName FROM Employee ORDER BY LastName", SqlConn); SqlConn.Open(); ddl.DataSource = SqlCmd.ExecuteReader(CommandBehavior.CloseConnection); ddl.DataTextField = "LastName,FirstName"; ddl.DataValueField = "UID"; ddl.DataBind(); } I don't get any errors, just that the dropdown list doesn't contain any data. Thanks again for all your help. Sincerely, Tim
Answers (11)