开发者

Binding collection from wcf response to a dropdownlist

I've a wcf service which returns a generic list : List lstAccount. The presentation layer client in my winforms app is using proxy object to connect to this service.

In the proxy, Account class gets generated like this:

    [System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4506.2152")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.X开发者_运维技巧ml.Serialization.XmlTypeAttribute(Namespace="http://schemas.datacontract.org/2004/07/Test.Common")]
    public partial class Account {}

When I bind this lstAccount to a dropdownlist on the form in my presentation layer[by setting the datasource property],the dropdownlist just shows the class name "Account" instead of shwoing account name.

this.cblExistingAccounts.DataSource = lstAccount;
this.cblExistingAccounts.DisplayMember = "Name";

What am i missing over here?

Thanks.


Make sure the properties of the account class on the service side are decorated with the DataMember attribute.

EDIT: Make sure that your proxy is up to date as well, try refreshing it and see if it fixes the issue.


Modify the binding like:

this.cblExistingAccounts.DataSource = lstAccount;
this.cblExistingAccounts.DataTextField = "Name";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜