Home All Groups Group Topic Archive Search About
Author
8 Nov 2005 4:37 PM
Lorenzo
Hello there,
I am struggling with somenthing that might be a little too advanced (for
me).  Thanks for any help in advance.

I have a database table that contains reservations for apartments, the table
structure is as follow:

IDReservation, IDApartment, dteArrival, dteDeparture etc.

What I would like to do is having the asp net calandar control render those
dates that are included in the table as taken coloring the differently.
I understand that I should use the onDayRender event but I have no idea how
to the code should go...!!!
Right now I don't think to add any further functionality to my calendar I
only need to display the color for example red for dates that are taken!

I don't have much so far in mind...

I can retrieve a dataset for my Reservation table and then have a subroutine
looking into the rows to see what dates are taken but how to?

Ciao Lorenzo

Author
13 Nov 2005 11:38 PM
JosephZet
You should retreive data for the selected month only.

Then your code could look like:

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
// weekends closed
if (e.Day.IsWeekend)
e.Day.IsSelectable = false;

// show status as specific color
for (int x = 0; x < _MyData.GetLength(0); x++)
{
if (_MyData[x].Date == e.Day.Date )
{
e.Cell.ForeColor = System.Drawing.Color.LightSalmon;
}
}
}

Of course you should walk through the dataRows of your datatable rather than an array.

Hope this helps.
JosZ -- JosephZet ------------------------------------------------------------------------ JosephZet's Profile: http://www.hightechtalks.com/m258 View this thread: http://www.hightechtalks.com/t2280318