DataTextField in a ListBox is a combination of 2 fields
问题 I have a listbox containing Users. The datasource is an generic list of the type User (contains, id, firstname, lastname, ...). Now I want to use the id as datavalue (through dataValueField) and I want LastName + ' ' + Firstname as a DataTextField. Can anyone tell me how this is possible? I'm using C# (ASP.NET). 回答1: The easiest way is to add a new property to the User class that contains the full name: public string FullName { get { return LastName + " " + FirstName; } } And bind the listbox