Solved

datatable in asp.net - merge

Posted on 2011-03-07
4
457 Views
Last Modified: 2012-05-11
Is there a way to merge year, make and model columns to one column, year_make_model?


datatable_1

orderdate      year      make      model
03/07/2011      2003       honda      civic exc

after

orderdate       Year_make_model
0
Comment
Question by:VBdotnet2005
  • 2
4 Comments
 
LVL 3

Expert Comment

by:chrisrbloom
ID: 35062249
Dim stYear, stMake, stModel, stCombined as String

stYear = {get year from datatable}
stMake = {get make from datatable}
stModel = {get model from datatable}

stCombined = stYear + " " + stMake + " " + stModel
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35062265
HI,

Did you application allows you to do it from the data source?  I mean from your query, something like this (assuming you are using SQL Server)

Select OrderDate, Convert(varchar, Year) + '_' + Make + '_' + Model As Year_Make_Model
From yourtable

or you have to do it once the data is in memory?
0
 

Author Comment

by:VBdotnet2005
ID: 35063921
Once the data in memory
0
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35064276
Hi,

After you populate you Datatable_1, you can add a Calculated column like this

datatable_1.Columns.Add("Year_Make_Model", GetType(System.String), "Year + ',' + Make + ',' + Model")

And after that you can read the value from the new merge column

        MsgBox(datatable_1.Rows(0)("Year_Make_Model"))
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

20 Experts available now in Live!

Get 1:1 Help Now