Solved

Combine two columns

Posted on 2016-09-29
3
43 Views
Last Modified: 2016-09-30
Hi,

I am getting a dataset from a query, I would like to combine two fields into one. This is my code, but I am getting error. any ideas?  thanks

        DataSet ds = new DataSet();
        da.Fill(ds);

        listBox1.DataTextField = ds.Tables[0].Columns["Name1"].ToString();
        
        ds.Tables[0].Columns.Add("CombineName", typeof(string), "Name1 + '*' + Name2");
        listBox1.DataValueField = ds.Tables[0].Columns["name"].ToString();



        listBox1.DataSource = ds.Tables[0];
        listBox1.DataBind();

Open in new window

0
Comment
Question by:mcrmg
[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 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 41822960
you can combine them in your query and get it in the results as below so that you dont need to add it in the code like below:

select concat(Name1,'* ', Name2) as CombineName
from yourTable

so just add "concat(Name1,'* ', Name2) as CombineName" in your query
1
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 41822982
What kind of error do you get?
0
 

Author Closing Comment

by:mcrmg
ID: 41823745
thank you
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Content Page 3 52
Asp.Net Session Question 2 36
disadvantage of code behind appoarch in asp.net 3 29
Validation for a field in asp.net 3 14
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

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