Display Tabulated Data (VS2008 ASP.NET C#)

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
This is going to be fun to explain... I have a DATABASE that contains the following data:

-DATE--------TIME----LEVEL
19/11/2008 - 8:00am - 05
19/11/2008 - 9:00am - 10
20/11/2008 - 8:00am - 06
20/11/2008 - 9:00am - 11
21/11/2008 - 8:00am - 12

So there is a column for DATE, a column for TIME, and a column for LEVEL. However, I need to display the data in a different format, specifically something like this


------------8:00am--9:00am
19/11/2008 -- 05 --- 10
20/11/2008 -- 06 --- 11
21/11/2008 -- 12

Notice that I have changed the orientation of the data, instead of having a row per Date/Time I now have columns that are TIME and rows that are DAYS and the intersection is the corresponding LEVEL.

Is there an easy way to transform the original data from the Database into such a format so I can use somekind of element to display it to the user? Like a gridview or whatever works best?

Any help would be greatly appreciated.
Thanks,
 
Which version of the Framework are you targeting? 2.0, 3.0, 3.5? Is using Linq an option? What dbms are you using? Access, SQL server, MySQL?

You need to get all of your records from the database, then get a distinct list of Dates, then for each distinct date, write out the time and level for each record with that date.

ex:
Code:
data = select * from table;
distinct = Enumerable.Dinstinct(Data.DATE);

foreach(row in (from d in data where d.DATE == distinct select d))
    response.write(row.TIME + " " + row.LEVEL);
 
Back
Top