Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid custom columns

Status
Not open for further replies.

Zarcom

Programmer
May 7, 2002
1,275
CA
I am not sure if it was possible to do this with a datagrid so I thought I would post the question to the masses since I can't find a reference to it on google.
Anyway on with the show.

I have some data that in a normal table looks like this.

Class | Price | Type | Date

Now for any particular class I was hoping to get a display running something like so.

Date | Type | Type | etc...
date field | price for this type| price for this type| etc...

Now I can retrieve the Types from another table I just want one column for each type with the prices listed under it.

Is this doable with a datagrid or should I be using a datalist perhaps. That'l do donkey, that'l do
[bravo] Mark
 
Mark -

Good quesiton. My first instinct, if I were facing the problem, is to go ahead and use the datagrid and develop an SQL statement that creates a X-Tab (Pivot) table. I looked in several of my ASP.NET books and not a single listing of Cross-Tab or Pivot tables in the index of any of them. I would start with something like:

TRANSFORM ... AS ...
SELECT ......
FROM .......
GROUP BY .......
PIVOT .....

...just an idea....
 
SQL BOL has some good info on how to create a pivot.

Their example uses a series of CASE statements, which won't dynamically change, though, if your number of types does.

If the number of types stays constant, however, it's a good solution.

:)
paul

ps. they show a method creating a temp table, whereas I lean more towards the view approach.
penny1.gif
penny1.gif
 
Thanks for the ideas guys I am researching them now.

Question for Paul. Excuse my ignorance but what is SQL BOL?

Isadore I was reading that T-SQL doesn't have the transform command

Any way I am now wading through resources looking stuff up. That'l do donkey, that'l do
[bravo] Mark
 
Books OnLine

Just their term for their documentation (why not just call it the docs?)

:)
paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top