ASP.NET Drop Down Not Populating


#1

Hi can someone help me. I added select2 to an asp.net app, but it’s not displaying the items that have been bound to the drop down. I set a break point on the drop down in the code-behind and I can see the values are their, but in the UI the drop down is empty when I expand it.

I’ve added the javascript and css references to my master page. Here is my aspx.
<asp:DropDownList ID="ddlManagers" runat="server" ClientIDMode="Static" CssClass="form-control"></asp:DropDownList>

Here is my code-behind where I populate and bind the drop down

var managers = db.users.Where(i => i.manager == true).Select(u => new { id = u.mgrUserId,  manager = u.lname + ", " + u.fname }).ToList();
 ddlManagers.DataTextField = "manager";
 ddlManagers.DataValueField = "id";
 ddlManagers.DataSource = managers;
 ddlManagers.DataBind();
 ddlManagers.Items.Insert(0, new ListItem("", ""));

I’d really appreciate some help in getting the values to actually display.
Thanks


#2

I don’t know much about asp.net, and I can’t see the generated HTML and JavaScript code from your example, so I can’t do much troubleshooting for you.

Is it possible for you to put your code (or at least the generated HTML and JS) on a site like jsfiddle.net or codepen.io?


#3

Thanks for the reply. I must of had something weird going on with my Visual Studio, because it is now working fine.