Solved

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

Posted on 2011-03-24
3
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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