Fixed datagrid

goran

New member
Joined
May 1, 2007
Messages
3
Programming Experience
Beginner
Hi !

I have datagrid showing orders from 8:00 till 16:00 o'clock. I'd like to show for example order at 10 o'clock always in third row of my grid even if other rows are empty.

thanks
 
if i put order by time it works Ok but if i want to show those empty rows in grid i'd have to ensure that datasource contains info for all times?

How to do that with empty rows? Sproc that will run with valuechange event and enter time in grid? Just a guess...
 
I'm not quite sure what you mean.. i'd write a query that returns a list of times and any events associated with that time, or nulls if there were no events. In oracle this could be pulled with a little trick like this:

VB.NET:
SELECT
  evt_time,
  events.*
FROM
  (
    SELECT
      trunc(sysdate) + (rownum + 7)/24 as evt_time
    FROM
      some_table_with_more_than_9 rows
    WHERE
      rownum < 10
  ) time_fake
  LEFT OUTER JOIN
  events
  ON
    evt_time = events.time

This takes a table, any table we dont care, with enough rows and pulls 9 rows out of it. We dont care what these rows are, we just want an increasing number from 1 to 9.
We take the current date today and chop the time off with trunc(), and then we take our row number 1 - 9 and turn this into a time of day from 8 am to 4pm by adding 7 to the rownum, and dividing it by 24 (because there are 24 hours in a day)

so our rownum:
1
2
3

becomes
8
9
10

becomes:
8/24
9/24
10/24

added to today's date, and we get datetime values of:
2 may 07, 8am
2 may 07, 9am
2 may 07, 10am


-
then, we left outer join that to our events table.
any event with a time mathcing that, will be included. if there is no event, then we get nulls:

2 may 07 8am, swimming, pool, $5
2 may 07 9am, doctors, town, $0
2 may 07 10am, null, null, null


genius eh?
 
Back
Top