开发者

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();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜