DataSet transpose in ASP.NET

Posted on 2011-10-05
Last Modified: 2012-05-12
In my ASP.NET code (C# Visual Studio 2008) I am have obtained this dataset by querying the Oracle database table:

The dataset looks like this:
However the number of columns (here it is 4) is not constant in the obtained dataset.
f1             f2                            f3                    f4
AAA              Lead_of_AAA      10/2/2011      4
AAA              Lead_of_AAA      10/9/2011      5
AAA              Lead_of_AAA      10/16/2011      8
BBB      Lead_of_BBB      10/2/2011      7
BBB      Lead_of_BBB      10/9/2011      0
BBB      Lead_of_BBB      10/16/2011      5
CCC      Lead_of_CCC      10/2/2011      3
CCC      Lead_of_CCC      10/9/2011      1
CCC      Lead_of_CCC      10/16/2011      8

How could I transpose this data set to obtain a dataset like:

f1       f2                        10/2/2011    10/9/2011  10/16/2011
AAA   Lead_of_AAA    4                     5                8
BBB   Lead_of_BBB  7                      0               5
CC    Lead_of_CCC  3                      1               8

Here I could assume f3 contents are string variable (not dates).
I am trying to do exactly opposite (converse) of what was done in .
Question by:toooki
    LVL 4

    Assisted Solution


    Please refer the link below.
    In this the function 'GenerateTransposedTable' transpose a datatable and returns the result as datatable
    LVL 53

    Accepted Solution


    Author Comment

    Thank you.
    The link in
    worked for me.
    I could create a DataTable with required columns in the gridview.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    This video discusses moving either the default database or any database to a new volume.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now