Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now