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";
精彩评论