I am trying to create a hotel booking calendar that selects the DateFrom and DateTo
I need to iterate through from the DateFrom to DateTo and display all these dates in the calendar, the code I have so far only selects the DateFrom and DateTo and displays them in the calendar as a label:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
DateTime df = (DateTime)dr.Field<DateTime?>("DateFrom");
DateTime dt = (DateTime)dr.Field<DateTime?>("DateTo");
if (e.Day.Date == dt.Date)
{
Label lbl = new Label();
lbl.BackColor = System.Drawing.Color.Gray;
lbl.Text = "Booked From";
e.Cell.Controls.Add(lbl);
}
if (e.Day.Date == df.Date)
{
Label lbl = new Label();
lbl.BackColor = System.Drawing.Color.Gray;
lbl.Text = "Booked To";
e.Cell.Controls.Add(lbl);
}
}
Not changing your code to much I would do this: