473,396 Members | 1,814 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,396 software developers and data experts.

dropdownlist-concat two fields-can it be done

ctb
I am not sure how to, or even if you can do this. I have
tried several things.
I have a drop down list that is databound to a
datareader. I wish to set the DataTextField to a
concatentation of first and last name that are stored in
the database.

any idea if there is a way to do this?
Thanks
Nov 17 '05 #1
2 6770
ctb
I will try this, especially the first option
but, one more question
I also bind the datafieldvalue to the Member_id in the
drop down list.
In my select statement can I select another field
(member_id) in addition to the concatenated fields in the
AS clause.
-----Original Message-----
There are two approaches to this:

1) Concatenate the fields in your select statement from the database "SELECT(lastName + ', ' + firstName) AS fullName From tblNames

2) You could concatenate the fields in the drop down's OnItemDataBoundevent.

The first way is probably the more efficient one.

I hope this helps.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"ctb" <cl***@speakeasyinteractive.com> wrote in message
news:08****************************@phx.gbl...
I am not sure how to, or even if you can do this. I have tried several things.
I have a drop down list that is databound to a
datareader. I wish to set the DataTextField to a
concatentation of first and last name that are stored in
the database.

any idea if there is a way to do this?
Thanks

.

Nov 17 '05 #2
Yes, you can select as many fields as you want!

SELECT Member_id, (lastName + ', ' + firstName) AS fullName From tblNames


--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"ctb" <cl***@speakeasyinteractive.com> wrote in message
news:09****************************@phx.gbl...
I will try this, especially the first option
but, one more question
I also bind the datafieldvalue to the Member_id in the
drop down list.
In my select statement can I select another field
(member_id) in addition to the concatenated fields in the
AS clause.
-----Original Message-----
There are two approaches to this:

1) Concatenate the fields in your select statement from

the database "SELECT
(lastName + ', ' + firstName) AS fullName From tblNames

2) You could concatenate the fields in the drop down's

OnItemDataBound
event.

The first way is probably the more efficient one.

I hope this helps.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"ctb" <cl***@speakeasyinteractive.com> wrote in message
news:08****************************@phx.gbl...
I am not sure how to, or even if you can do this. I have tried several things.
I have a drop down list that is databound to a
datareader. I wish to set the DataTextField to a
concatentation of first and last name that are stored in
the database.

any idea if there is a way to do this?
Thanks

.

Nov 17 '05 #3

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

Similar topics

0
by: DotNetJunkies User | last post by:
Hie, I create a dynamique HtmlTable, in each cell of this HtmlTable put a new control ( dropdownlist,label,..) and then want to create handler so that if i change the select item in the dop downlist...
12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
2
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. ...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
1
by: Shaun Camilleri | last post by:
Hi all, I am creating a DropDownList in a RepeaterControl. After the Repeater is DataBound in the ItemCreated event (of the Repeater) I bind the DropDownList to a Table and then try to select one...
0
by: Juanjo | last post by:
Hi, Before, I was working with Asp.net 1.0 and datagrid. I posted a question for this issue. The solution of this problem is load the second dropdownlist on the selectedindexchanged event of the...
2
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine...
1
by: pleaseexplaintome | last post by:
Hi all, I have a datagrid with a dropdownlist and would like to have the dropdownlist display a database value correctly while the grid is in edit mode. I have a templatecolumn as follows: ...
0
by: andy | last post by:
Hi, I have a form uses several dropdownlists to narrow a set of criteria. ( This is in turn used to control what is shown on a gridview. ) With each, the user selects an entry and then the next...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.