Gridview data binding HELP!!

S

Saint

I'm doing a little reservation website and I have two tables: Modules
and Reservation

In MODULE I have every module from a doctor with the day and the hours
that he goes to work, for example:

doctor | module | hour | day
--------------------------------------------
1 1 10:00 1
1 2 10:30 1
1 3 11:00 1
1 4 09:00 2
1 5 09:30 2

This says that the Doctor 1 works from 10:00 until 11:00 on Monday,
from 9 to 9:30 on Tuesday

And in RESERVATION I got:

date | hour | doctor
-----------------------------------------
25/12/06 10:00 1
25/12/06 11:00 1

This says that Doctor 1 has a reservation for day 25 (wich is Monday =
1) at 10:00 and at 11:00

I HAVE to fill my gridview from de MODULE table with ALL the hours
available for that doctor in certain date (I got covered that with a
calendar control).
So, for default that would look like this:

HOUR | STATE
-------------------------
10:00 | Available
10:30 | Available
11:00 | Available
11:30 | Available

But in the case that one o more of the hours are reserved (making a
query in the RESERVATION table), then would look like this:

HOUR | STATE
-------------------------
10:00 | Reserved
10:30 | Available
11:00 | Reserved
11:30 | Available

My problem is that I don't know how to generate the states while the
gridview is being filled :S
I hope is clear.... please please help me with this!!!
 
B

Bill Nicholson

I think you need to write a query that joins the two tables and bind
that dataset to the grid. The query should use a left outer join to
that every record in the doctor table appears regardless of whether or
not there's a corresponding record in the reservation table.

SELECT doctor.*, reservation.* from doctor LEFT OUTER JOIN reservation
WHERE doctor.doctorID = reservation.doctorID.

You can bind that dataset to the grid, either at design time or at run
time.

Bill Nicholson
..Net Dufus
Cincinnati, OH USA
 

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

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,187
Latest member
RosaDemko

Latest Threads

Top