473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Dataset filling ListBox

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
Nov 19 '05 #1
3 1285
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
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #2
Do it in SQL as Justin advice and you can also TRIM it before rendering it.
Patrick
"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:um*************@TK2MSFTNGP15.phx.gbl...
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
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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


Nov 19 '05 #3
"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:um*************@TK2MSFTNGP15.phx.gbl...
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
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: lakshmi | last post by:
Hi all, My requirement is I need to have three different recordsets open at the same time. Traversing through the 3 recordsets, I would check on the data and based on some rules, return an object...
3
by: Tee | last post by:
Hi, I need some help about filling dataset, I am not sure how to describe it, so I give the example here. da = new OleDbDataAdapter("SELECT * FROM Path WHERE PathID=1", cnn); ...
1
by: Krzysztof Karnicki | last post by:
I have such a problem… I have create my custom DataGridColumn inheriting from System.Windows.Forms.DataGridColumnStyle on using it on DataGrid, to show rows painted by me self. Because dates ...
2
by: Jake | last post by:
Hello, I have a web page that has a listbox. I want to populate the listbox based upon the dataset that is returned from a webservice. The data set returns two columns of data. The first column...
5
by: Monty M. | last post by:
Hello; I was wondering if anyone can assist me with this problem. Here are the tools I am using: Language: C# Database: MS SQL Server 2000 Application: Visual Studio 2005 1. I have a...
2
by: rrflore2 | last post by:
Ok. I'm writing and deleting to an xml file using a dataset. I have a function in my codebehind page that binds a listbox to the dataset that performs the writes/deletes. Everything seems to be...
1
by: MariaKhan | last post by:
?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ???
1
by: sweetiecakes | last post by:
Hi I have a ListBox which is binded to a dataSet. When I need to refresh this dataSet, it works, but the old entries don't get removed from the listbox. Items.Clear() doesn't work when a...
0
by: Alberto Poblacion | last post by:
"JB" <jamesb457@gmail.comwrote in message news:3c8d65e6-9993-4d46-8a01-a11e89ca745d@e39g2000hsf.googlegroups.com... Something is wrong here. You are filling a DataSet called "dataSet", but you...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.