I have a Dropdown List in the asp page which I bind it in codebehind.
<asp:DropDownList ID="authorList" runat="server"></asp:DropDownList>
In C#,
PublishingCompanyEntities p = new PublishingCompanyEntities();
var a = (from s in p.Authors
select s.FirstName);
authorList.DataSource = p.Authors;
authorList.DataTextField = "Firstname";
authorList.DataValueField = "FirstName";
where PublishingCompanyEntities is an entity class got using ADO.NET Entity model. However, the dropdownlist is not getting binded. Can u let me know the mistake I’ve been making?
Try calling the
.DataBind()method on the drop down after assigning theDataSourceproperty:Contrary to WinForms, in ASP.NET you need to invoke this method explicitly.