how can we bind two fields from a table to a dropdownlist as datatextfield

Hi,
I have a dropdownlist which i want to display employee surname &  first name seperated by comma e.g. Murphay,David. Data is binded from a datatable that is pulled from  a stored procedure. and this is a generic stored procedure that cant be changed & i cant concatenate surname and firstname in sql. Is there any other way that we can use to display surname and first name in the dropdownlist
I am using Asp.net with Vb.net in VS 2005 with sql server 2005
Thanks in advance
mmalik15Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zkeownCommented:
Once you have your datatable, but before you bind to the dropdownlist, can you do:

DropDownList1.DataTextField = dt.Columns("LastName") & ", " & dt.Columns("FirstName")

?
0
mmalik15Author Commented:
thanks for your prompt answer looks gud but i am getting an error wth concat operator which says
"Error      2      Operator '&' is not defined for types 'System.Data.DataColumn' and 'String'.      "
0
zkeownCommented:
Oops, knew it wasn't that easy.

You're going to have loop through the datatable and add a new listitem for each row.  See the following link for an example.

http://forums.asp.net/p/613352/615516.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Sachintana DissanayakeSenior Web DeveloperCommented:
zkeown comment is not valid, bu you can do it in row data binding event.

I think it's better if you can get only one single column from the SQL select statement.
    SELECT User_Id, (Last_Name + ', ' + First_Name) AS FullName
    From tblUsers
0
mmalik15Author Commented:
Thanks for your comments. Much Apprecicated
0
Sachintana DissanayakeSenior Web DeveloperCommented:
Sorry, the very first comment from zkeown is invalid.
But the next comment is correct, which was submitted at the same time with my comment.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.