Solved

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

Posted on 2011-03-24
3
382 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 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