Solved

datatable in asp.net - merge

Posted on 2011-03-07
4
458 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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