Dataset filling ListBox

T

tshad

I have the following code:

UserList.DataSource=theDataSet
UserList.DataTextField= "FirstName" & " " & "LastName"
UserList.DataValueField="UserID"
UserList.databind()

This, of course, doesn't work as you can't use 2 fields from the dataset.

I already have the Sql Combining the Names to FullName and the line now
looks like:

UserList.DataTextField= "FullName"

My question is - is there a way to Databind the text field with multiple
fields?

There are other cases where I want to combine dates and fields that I am
doing in SQL before databinding, but I was curious if there was a way to do
it programmatically (not using a loop, but using databind).

Not a big deal, just curious.

Thanks,

Tom
 
S

S. Justin Gengo

Tshad,

A loop is already built into the databind. The event OnItemDatabound is
fired as each item is bound to the list. You can use OnItemDatabound to
break into the loop per item and do things like combine fields there. But
you're much better off combining the fields in SQL since that is more
efficient.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
P

Patirck Ige

Do it in SQL as Justin advice and you can also TRIM it before rendering it.
Patrick
 
T

tshad

S. Justin Gengo said:
Tshad,

A loop is already built into the databind. The event OnItemDatabound is
fired as each item is bound to the list. You can use OnItemDatabound to
break into the loop per item and do things like combine fields there. But
you're much better off combining the fields in SQL since that is more
efficient.

I agree.

I was just curious about doing in my program. But as you say much more
efficient on the SQL side.

Thanks,

Tom
 

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,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top