Solved

Combine two columns

Posted on 2016-09-29
3
37 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
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
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.…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

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

22 Experts available now in Live!

Get 1:1 Help Now