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 / General / February 2008

Tip: Looking for answers? Try searching our database.

data format in grid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 07 Feb 2008 16:03 GMT
I'm tyring to have my data in a side by side format for each year so the
user can compare the data together.
Here is how my data is being returned to me from the database;

year        sales        gains        loss
2007        20            1,000        200
2006        10            1500        150

I want to show the data like this:

               2007                2006
sales        20                    10
gains        1,000                1500
loss          1500                150

is this possible to do, and what would be the best way to do this?
Mark Rae [MVP] - 07 Feb 2008 16:19 GMT
> Is this possible to do,

Yes.

and what would be the best way to do this?

Depends what options you have for modifying the way the data is returned to
you...

You don't say where the data is coming from, so I'm assuming it's SQL
Server. If you are able to modify the server query, do a Google for

"SQL Server" crosstab

Google will return many examples for transforming the data in the way that
you need.

If you can't modify the data source, then I'd suggest you investigate the
<asp:Repeater> control...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Tom - 07 Feb 2008 16:26 GMT
correct, its coming a SQL database.

>> Is this possible to do,
>
[quoted text clipped - 15 lines]
> If you can't modify the data source, then I'd suggest you investigate the
> <asp:Repeater> control...
Mark Rae [MVP] - 07 Feb 2008 16:40 GMT
>> You don't say where the data is coming from, so I'm assuming it's SQL
>> Server.
>
> Correct, it's coming a from SQL Server database.

No problem, then...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Tom - 07 Feb 2008 17:05 GMT
I can get the data out as

year        sales        gains        loss
2007        20            1,000        200
2006        10            1500        150

and in my grid I have it showing as

sales        20
gains        1000
loss        1500

how can I add my 2006 data so it shows like this in either on grid or
repeater control

                   2006                2007
sales            10                    10
gains           1500                1000
loss            10                    150

and so on. I have a portion of it working but now I need the bottom portion
of this to work

>>> You don't say where the data is coming from, so I'm assuming it's SQL
>>> Server.
>>
>> Correct, it's coming a from SQL Server database.
>
> No problem, then...
Mark Rae [MVP] - 07 Feb 2008 17:13 GMT
> I need the bottom portion of this to work

http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_
en-GBGB252GB252&q=%22SQL+Server+2005%22+crosstab


Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Tom - 07 Feb 2008 17:16 GMT
I'm looking at them now and it appears that they won't do what I want to do.

I have the table pivoting in my sql, its the seperation of the years that
I'm stuck on.

>> I need the bottom portion of this to work
>
> http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_
en-GBGB252GB252&q=%22SQL+Server+2005%22+crosstab

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.