Dropdown list not getting binded
I have a Dropdown List in the asp page which I bind it in codebehind.
<asp:DropDownList ID="authorList" runat="server"></asp:DropDownL开发者_JAVA技巧ist>
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 the DataSource
property:
authorList.DataBind();
Contrary to WinForms, in ASP.NET you need to invoke this method explicitly.
I don't see a call to authorList.DataBind();
精彩评论