Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9279775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:42:54+00:00 2026-06-18T17:42:54+00:00

I have the data table below. I would like to change the data table

  • 0

I have the data table below. I would like to change the data table to transform the data table into the one next to it. How can I do this?

The reason why i would like o do this is because the excel file brings the data in like shown and then i would like to sort this data out on Row 1

Current table

      || Col 1 || Col 2 || Col 3
____________________________________    
Row 1 || 10    ||  20   || 30
Row 2 || 1     ||  2    || 3 

New Datatable

      || Row 1 || Row 2 
Col 1 ||  10   ||   1
Col 2 ||  20   ||   2
Col 3 ||  30   ||   3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:42:56+00:00Added an answer on June 18, 2026 at 5:42 pm

    .NET does not include a method to transpose data tables. You have to make your own. This website has a tutorial on an example transpose method. I will copy and paste the code snippet below:

    private DataTable Transpose(DataTable dt)
    {
        DataTable dtNew = new DataTable();
    
        //adding columns    
        for(int i=0; i<=dt.Rows.Count; i++)
        {
           dtNew.Columns.Add(i.ToString());
        }
    
    
    
        //Changing Column Captions: 
        dtNew.Columns[0].ColumnName = " ";
    
         for(int i=0; i<dt.Rows.Count; i++) 
         {
          //For dateTime columns use like below
           dtNew.Columns[i+1].ColumnName = Convert.ToDateTime(dt.Rows[i].ItemArray[0].ToString()).ToString("MM/dd/yyyy");
          //Else just assign the ItermArry[0] to the columnName prooperty
         }
    
        //Adding Row Data
        for(int k=1; k<dt.Columns.Count; k++)
        {
            DataRow r = dtNew.NewRow();
            r[0] = dt.Columns[k].ToString(); 
            for(int j=1; j<=dt.Rows.Count; j++)
            r[j] = dt.Rows[j-1][k];  
            dtNew.Rows.Add(r);
        }
    
     return dtNew;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
I have a table that has data like below(sorted by date) COL_A | COL_B
basically I have a table grid like the one below, just a lot bigger.
I do have a table data as shown below: <td> <label for=title>Title : </label>
I have a piece of matlab code below which reads data from a table.
I have a table part with a few demo data as below in Oracle
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
I have a data table with many rows and columns. How can I display
I have my database with 3 tables like so: Orders table has data like
I have data arranged like this in R: indv time val A 6 5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.