Combining 2 Fields Using ListBox.DataTextField

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

I have a ListBox control which I am using with databinding. However, the
text that I want to be displayed is a combination of two fields (in this
case, first and last names). What do I enter as the DataTextField property
to combine these two fields? Thanks.
 
D

Darren Kopp

Well, for a general purpose answer... this should work.

list.DataTextField = string.Forma("{0}, {1}", FirstNameVar, LastNameVar);

FirstNameVar and LastNameVar are string variables or you could use really
anything, I'm sure you get the basic idea.


HTH
-Darren Kopp
http://blog.secudocs.com/
 
D

Darren Kopp

oops, string.Format.

-Darren

Darren Kopp said:
Well, for a general purpose answer... this should work.

list.DataTextField = string.Forma("{0}, {1}", FirstNameVar, LastNameVar);

FirstNameVar and LastNameVar are string variables or you could use really
anything, I'm sure you get the basic idea.


HTH
-Darren Kopp
http://blog.secudocs.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top