Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting List of Formatted Names
Message
De
23/12/2010 17:29:09
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
23/12/2010 15:36:21
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01493720
Message ID:
01493751
Vues:
40
>>>Hi,
>>>
>>>this is MM.NET 3.6, but maybe is more general than that.
>>>
>>>I have an Agents table with an Agent Business Object. I need to display a dropdown list of Agents for the user to select. The Agents' names must be formatted "Surname, Firstname Middlename".
>>>
>>>Do I:
>>>
>>>1. Add in a formatted/calculated field to the table and then add this field to the BO?
>>>
>>>2. Add in a field called FullName to the stored procedures that the BO calls to get the data? Or
>>>
>>>3. Add in a calculated property on the BO?
>>
>>I would not use option 1, option 2 and 3 are both OK. If this list will just be a list of names for the dropdown list then I would just use option 2 and return a dataset to bind to the combo. I do a similar thing where I display the names in a grid and I return from the stored procedure the lastName, FirstName as Fullname.
>>
>>You could also add a property on the Entity that puts the two together and bind to that property rather than the others. Just don't let the property attempt to update since you may use that entity object elsewhere.
>>Tim
>
>Thanks and Merry Christmas.
>
>Too Late, I already did option 1 :)
>
>But I'd prefer to do option 3 or your suggestion of the property on the Entity. Can you give me a push in the right direction as I'm at a loss where to start.


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; }			
}
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform