Solved

datatable in asp.net - merge

Posted on 2011-03-07
4
461 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
[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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

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