Solved

how can I combine 2 columns from a dataset table as the datatextfield of a dropdown control?

Posted on 2011-03-24
3
376 Views
Last Modified: 2012-05-11
Hi, I'm using asp.net 3.5, C# and sql 2005 exp
How can I combine LastName and FristName column of a dataset table, separated by a comma as the ddb Datatextfield?  So it should display something like:
LastName, Firstname
Thank you.
0
Comment
Question by:lapucca
3 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 250 total points
ID: 35213013

Not sure got your question completely
but I think you have two columns in database like Fristname and LastName
and you want to combine it in one and then bind it to dropdown control

Tehn in this case you can get it from database itself as combined in query like

Select LastName + '," + Firstname as Name from Tablename

and bind NAme column to Drop down
0
 
LVL 1

Assisted Solution

by:StellerSystems
StellerSystems earned 250 total points
ID: 35213029
in your sql server 2005 view, i would concatenate the two fields into a new field called LastFirst or something like that, then just use that field for your control:

select Lastname, Firstname, LastName + ',' + Firstname LastFirst
From TableOfNames
order by Lastname, Firstname

then set your control accordingly

if either Lastname or  Firstname could be NULL, make sure you handle that or the whole string will be null:

isnull(LastName,'') + ',' + isnull(Firstname,'')
0
 

Author Closing Comment

by:lapucca
ID: 35213065
Thank you.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question