Rotating a DataGrid

S

Steve Heckler

Hi, All,

I'm helping a client solve a tricky problem. Any suggestions on the below?
Your help is greatly appreciated.

I'm looking to build a dynamic datagrid. Dynamic by columns. In other
words, the row result of a query will be the column headers. For example, a
query result of inventory by location:

Location Qty On Hand
Atlanta 12
Dallas 52
Pittsburgh 4
Chicago 16

Would show up in the datagrid as follows:
- -------------------------------------------------------------------
-
- Atlanta - Dallas - Pittsburgh - Chicago -
- 12 - 52 - 4 -
-
- -------------------------------------------------------------------
-

Any ideas on how to do this? Links to relevant online or .NET Framework SDK
articles would be fine. Thanks!
 
C

Craig

You could use a datalist with the RepeatDirection property set to
Horizontal.
That worked for me.
 
S

Steve Heckler

Alvin,

Terrific -- a big thanks to you and Craig for your helpful replies.

Steve


Alvin Bruney said:
Here is some code:
http://24.204.143.27/dotnet/flip.htm

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Steve Heckler said:
Hi, All,

I'm helping a client solve a tricky problem. Any suggestions on the
below?
Your help is greatly appreciated.

I'm looking to build a dynamic datagrid. Dynamic by columns. In other
words, the row result of a query will be the column headers. For example,
a
query result of inventory by location:

Location Qty On Hand
Atlanta 12
Dallas 52
Pittsburgh 4
Chicago 16

Would show up in the datagrid as follows:

- ------------------------------------------------------------------ -
-
- Atlanta - Dallas - Pittsburgh - Chicago -
- 12 - 52 - 4 -
-

- ------------------------------------------------------------------ -
-

Any ideas on how to do this? Links to relevant online or .NET Framework
SDK
articles would be fine. Thanks!
 
S

Steve Heckler

Alvin,

Thanks again for your help. Quick question for you: what code should
go in the [snip] regions that you marked? That's not clear to me. A
client of mine who just tried this code wrote me and said:

I ran it and it went from 3 columns and 4 rows to 2 columns and 3
rows, should have gone to 4 columns and 3 rows.......

Thoughts? I enormously appreciate your help.

Steve

Alvin Bruney said:
Here is some code:
http://24.204.143.27/dotnet/flip.htm

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Steve Heckler said:
Hi, All,

I'm helping a client solve a tricky problem. Any suggestions on the
below?
Your help is greatly appreciated.

I'm looking to build a dynamic datagrid. Dynamic by columns. In other
words, the row result of a query will be the column headers. For example,
a
query result of inventory by location:

Location Qty On Hand
Atlanta 12
Dallas 52
Pittsburgh 4
Chicago 16

Would show up in the datagrid as follows:
- -------------------------------------------------------------------
-
- Atlanta - Dallas - Pittsburgh - Chicago -
- 12 - 52 - 4 -
-
- -------------------------------------------------------------------
-

Any ideas on how to do this? Links to relevant online or .NET Framework
SDK
articles would be fine. Thanks!
 
A

Alvin Bruney [MVP]

[snip] code should be the number of times you repeat the two previous lines
to get sufficient columns.

Your client is missing an additional column, or the bounds on the for loop
are incorrect which is why he is coming up short.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Steve Heckler said:
Alvin,

Thanks again for your help. Quick question for you: what code should
go in the [snip] regions that you marked? That's not clear to me. A
client of mine who just tried this code wrote me and said:

I ran it and it went from 3 columns and 4 rows to 2 columns and 3
rows, should have gone to 4 columns and 3 rows.......

Thoughts? I enormously appreciate your help.

Steve

Alvin Bruney said:
Here is some code:
http://24.204.143.27/dotnet/flip.htm

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Steve Heckler said:
Hi, All,

I'm helping a client solve a tricky problem. Any suggestions on the
below?
Your help is greatly appreciated.

I'm looking to build a dynamic datagrid. Dynamic by columns. In
other
words, the row result of a query will be the column headers. For
example,
a
query result of inventory by location:

Location Qty On Hand
Atlanta 12
Dallas 52
Pittsburgh 4
Chicago 16

Would show up in the datagrid as follows:
- -------------------------------------------------------------------
-
- Atlanta - Dallas - Pittsburgh -
Chicago -
- 12 - 52 - 4 -
-
- -------------------------------------------------------------------
-

Any ideas on how to do this? Links to relevant online or .NET
Framework
SDK
articles would be fine. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top