Flipped Gridview Control

S

spitapps

In a traditional gridview control the items inserted(bind) into the
control are rows and the data is in columns. I have a customer who
wants the data fields as rows and the columns as the items being
inserted(bind). I have never seen a gridview control displayed in
this fashion but would like to use a control to accomplish this, so I
am wondering if this is possible or if someone has an idea on how to
accomplish this. Thanks.

normal gridview can I??
1 2 3

1 data data data
data data data

2 data data data
data data data

3 data data data
data data data
 
G

Guest

spitapps said:
In a traditional gridview control the items inserted(bind) into the
control are rows and the data is in columns. I have a customer who
wants the data fields as rows and the columns as the items being
inserted(bind). I have never seen a gridview control displayed in
this fashion but would like to use a control to accomplish this, so I
am wondering if this is possible or if someone has an idea on how to
accomplish this. Thanks.
<snip>

spitapps,

What you are asking for is often called a pivot, cross-tab, or rotated data.
Unfortunately, the GridView control does not directly support a cross-tab
mode. You'll have to either pivot your data inside your stored procedure or
select back the data into a DataTable and then pivot the DataTable.

I personally think rotating your DataTable is easiest, but that is a matter
of preference. If you rotate a DataTable then the pivot logic is simpler
(don't have to deal with dynamic sql) but have to manually bind the GridView
to your rotated DataSet. If you use sql 2005's pivot or dynamic sql, the
pivot logic is a bit more complex but you can bind the GridView using a
SqlDataSource.

There are a lot of links for this type of operation on Google. Here are a
few that you might find helpful.

Pivoting a DataTable/DataSet:
http://aspalliance.com/538

SQL 2005 pivot syntax:
http://www.programmersheaven.com/2/SQL-server-2005-school-lesson-4-p2

Using dynamic sql to pivot data (in case you are running on a database that
does not support a pivot syntax or if the pivot syntax is not adequate):
http://www.sqlteam.com/item.asp?ItemID=2955

Hope this helps,
Jason Vermillion
 

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

Top