Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / September 2005

Tip: Looking for answers? Try searching our database.

Pivot a datagrid?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
et - 17 Sep 2005 14:56 GMT
I seem to remember seeing an article on how to reverse the data in a grid,
so that each record creates a column rather than a row?  Does anyone know
how to do this?  Thanks for your help.
Elton Wang - 18 Sep 2005 15:35 GMT
Once rendering to cliend-side, a datagrid actually is html table. Hence if
you just want to show data in a grid, you can manually create html table
based on your data source, in a revering row/column arrangement.

Or you can reverse row/column in data source. For example, the data source
is a 8 columns and 5 rows datatable, you create a datatable with 5 columns
then assign data from first datatable to second datatable. After binding
datagrid's data source to the second datatable, it shows data in a reversing
behavior.

HTH

>I seem to remember seeing an article on how to reverse the data in a grid,
>so that each record creates a column rather than a row?  Does anyone know
>how to do this?  Thanks for your help.
eagle - 21 Sep 2005 17:08 GMT
That's an idea, although not sure how to do the second one.  You mean item
by item I would have to place into the 2nd table?  Could you give me some
code or pseudo code examples?

I also want pagination, hence the reason I am sticking to a grid.  Thanks
for you rhelp.

> Once rendering to cliend-side, a datagrid actually is html table. Hence if
> you just want to show data in a grid, you can manually create html table
[quoted text clipped - 11 lines]
>>so that each record creates a column rather than a row?  Does anyone know
>>how to do this?  Thanks for your help.
Elton Wang - 21 Sep 2005 19:27 GMT
Following is code snippet :

DataTable secondTable = new DataTable();
DataColumn col;
for (int I = 0; I < datasource.Rows.Count; I++)
{
    col = new DataColumn("Col" + I.ToString(),
Type.GetType("System.String"));
    secondTable.Columns.Add(col);
}

DataRow newRow;
for (int I = 0; I < datasource.Columns.Count; I++)
{
     newRow = secondTable.NewRow();
     for (int J = 0; J< datasource.Rows.Count; J++)
    {
        newRow[J] = datasource.Rows[J][I].ToString();
    }
    secondTable.Rows.Add(newRow);
}

HTH

> That's an idea, although not sure how to do the second one.  You mean item
> by item I would have to place into the 2nd table?  Could you give me some
[quoted text clipped - 18 lines]
> >>so that each record creates a column rather than a row?  Does anyone know
> >>how to do this?  Thanks for your help.
et - 22 Sep 2005 18:44 GMT
that works!  thanks so much for your help.

> Following is code snippet :
>
[quoted text clipped - 50 lines]
> know
>> >>how to do this?  Thanks for your help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.