Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting List of Formatted Names
Message
De
24/12/2010 08:33:55
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
24/12/2010 08:29:44
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01493720
Message ID:
01493784
Vues:
50
>>>>Pretty simple really just add a property to your Entity that looks something like this. Since it accesses the other properties they will be hooked up to the data row. Now bind your drop down to this property rather than the others.
>>>>
>>>>Merry Christmas to you also.
>>>>
>>>>public string FullName
>>>>{
>>>>	get { return this.LastName + ", " + this.FirstName + " " + this.MiddleName; }			
>>>>}
>>>>
>>>
>>>:( Afraid there must be something more to it than that. I did as you said and I get this error:
>>>
>>>DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'FullNameLFM'.
>>>
>>>This is my code which I put in the AgentEntity.cs:
>>>
>>>
        public string FullNameLFM
>>>        {
>>>            get { return this.LastName + ", " + this.FirstName + " " + this.MiddleName; }
>>>        }
>>>
>>>This is the dropdownlist definition:
>>>
>>>
            <mm:mmDropDownList ID="cboAgent" runat="server" BindingSource="Agent" BindingSourceDisplayMember="FullNameLFM"
>>>                AutoPostBack="true" BindingSourceValueMember="AgentPK" BindingValueSource=""
>>>                BindingValueSourceMember="">
>>>            </mm:mmDropDownList>
>>>
>>>Is there something else for me to do or did I put this in the wrong place?
>>
>>Frank,
>>
>>I just tried this by adding this property in a PersonEntity that I have.
>>
>>public string FullName
>>{
>>     get
>>     {
>>          return this.LastName + ", " + this.FirstName + " " + this.MiddleName;
>>     }
>>}
>>
>>
>>Then in a form I registerd the business object and called GetAllEntities. After looping through the entitylist, Printed out all the FullNames and it worked fine. See the code below which I put in a constructor just to try it. I would suggest you try this also to decide if the property works or if there is an issue with the way you are binding.
>>
>>
>>public PeopleManger()
>>{
>>	this.oPerson = (Person)this.RegisterPrimaryBizObj(new Person());
>>
>>	InitializeComponent();
>>
>>	this.oPerson.GetAllEntities();
>>	if (this.oPerson.Entity.HasValues)
>>	{
>>		foreach (PersonEntity entity in this.oPerson.EntityList)
>>		{
>>			Console.WriteLine(entity.FullName);
>>		}
>>	}
>>}
>>
>>
>>If that works then try binding it to a textbox or something less complicated than a drop down. Then if that works, will have to see why there is an issue in the binding of your drop down.
>>Tim
>
>Hi Tim,
>
>I think the problem is with the binding. It is currently set like this:
>
>
BindingSource="Agent" BindingSourceDisplayMember="FullNameLFM"
>
>But if I understand things correctly, this is trying to bind to the Agent, not the Agent.Entity. Is there a different way to bind a dropdownlist to an Entity List?

Frank,

The binding source is supposed to be set to the business object that contains the EntityList you are binding to. If Agent is that business object, then it appears you have it correct. However, since your binding does not indicate you are synchronizing it to another table foreign key you could just populate the combo. What do you do with the data in the combo once they select a value?
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform