Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Pivot a datagrid?

Reply
Thread Tools

Pivot a datagrid?

 
 
et
Guest
Posts: n/a
 
      09-17-2005
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.


 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      09-18-2005
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





"et" <> wrote in message
news:O6K4m%...
>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.
>



 
Reply With Quote
 
 
 
 
eagle
Guest
Posts: n/a
 
      09-21-2005
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.


"Elton Wang" <> wrote in message
news:...
> 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
>
>
>
>
>
> "et" <> wrote in message
> news:O6K4m%...
>>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.
>>

>
>



 
Reply With Quote
 
Elton Wang
Guest
Posts: n/a
 
      09-21-2005
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

"eagle" <> wrote in message
news:...
> 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.
>
>
> "Elton Wang" <> wrote in message
> news:...
> > 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
> >
> >
> >
> >
> >
> > "et" <> wrote in message
> > news:O6K4m%...
> >>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.
> >>

> >
> >

>
>



 
Reply With Quote
 
et
Guest
Posts: n/a
 
      09-22-2005
that works! thanks so much for your help.

"Elton Wang" <> wrote in message
news:%...
> 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
>
> "eagle" <> wrote in message
> news:...
>> 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.
>>
>>
>> "Elton Wang" <> wrote in message
>> news:...
>> > 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
>> >
>> >
>> >
>> >
>> >
>> > "et" <> wrote in message
>> > news:O6K4m%...
>> >>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.
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot table function in asp.net Grey ASP .Net 0 09-24-2004 07:20 AM
Pivot table control =?Utf-8?B?UG9udGlNYXg=?= ASP .Net 2 06-15-2004 08:32 PM
Re: Pivot table control Phil Winstanley [Microsoft MVP ASP.NET] ASP .Net 2 06-15-2004 04:26 PM
Re: Pivot table control Phil Winstanley [Microsoft MVP ASP.NET] ASP .Net 0 06-15-2004 11:29 AM
Create Pivot table =?Utf-8?B?QWpheQ==?= ASP .Net 4 02-16-2004 03:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57