We have a ASP.Net Calendar control, and in the DayRender event, we have the following code:
protected void calminical1_DayRender(object sender, DayRenderEventArgs e)
{
CheckBox mycb = new CheckBox();
e.Cell.Controls.Add(mycb);
}
This makes every day in the Calendar contain a CheckBox. The purpose and idea behind this is, an employee can apply for vacation time by simply selecting the days visually in the calendar that he/she wants off.
Problem is, I don’t know how to loop through the calendar to find out what days the user has checked.
For GridViews, I often use:
foreach (Row x in table.Rows)
{
//loop through all rows
}
Essentially I need to do the same thing, but for “cells” or “days” of the Calendar control. Most of these web controls have collections that are obvious and intuitive, i.e. dropdown list and other list controls have “Items”, tables and gridviews have “Rows”, but I can’t seem to find the equivalent for Calendar controls.
Here’s the code I ended up using to achieve what I was looking for. Maybe someone else will find it useful: