Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Combine two columns

Posted on 2016-09-29
3
Medium Priority
?
51 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

609 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