I'm really stumped here. I have a (c# 2.0) calendar control that loads a menu for each day inside the cell corresponding to that day in the dayrender event. That is all working great. I have no idea how to figure out whether anyone checked any of the boxes, though! I've tried to loop through the controls to see if any are checkboxes, but I can't seem to get "inside" the calendar itself.
Any ideas or guidance would be appreciated.
Code for the dayrender:
Expand|Select|Wrap|Line Numbers
- protected void LunchCalendar_DayRender(object sender, DayRenderEventArgs e)
- {
- {
- //if (e.Day.IsWeekend)
- //{
- // e.Cell.Visible = false;
- //}
- DateTime daDate = DateTime.Parse(e.Day.Date.ToString());
- if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
- {
- // Set the width as it will have data
- e.Cell.Width = 140;
- // DataRow[] rowTest = dtService.Select(string.Format("[ServiceDate] = '{0}'", e.Day.Date));
- DataRow[] rowsExisting = dtExisting.Select("LunchDate = '" + daDate + "'");
- DataRow[] rowsService = dtService.Select("ServiceDate = '" + daDate + "'", "CategoryName ASC, ProductName DESC");
- if (rowsExisting.Length == 0 && rowsService.Length == 0)
- {
- e.Cell.Controls.Add(new LiteralControl("<br /><br />"));
- e.Cell.Controls.Add(new LiteralControl("<br /><br /><center>"));
- Label labelNone = new Label();
- labelNone.ForeColor = System.Drawing.Color.Black;
- labelNone.Font.Name = "Verdana";
- labelNone.Font.Size = FontUnit.Point(10);
- labelNone.Font.Bold = true;
- labelNone.Text = "No Lunches Available";
- e.Cell.Controls.Add(labelNone);
- e.Cell.Controls.Add(new LiteralControl("</center>"));
- }
- // Create a label to print ordered info of each returned row.
- for (int i = 0; i < rowsExisting.Length; i++)
- {
- Label label = new Label();
- label.Text = rowsExisting[i][0].ToString() + " ea. " + rowsExisting[i][3].ToString();
- e.Cell.Controls.Add(label);
- e.Cell.Controls.Add(new LiteralControl("<br />"));
- }
- // Create a check box control to use for ordering of each returned row.
- if (rowsService.Length > 0)
- {
- string category = "";
- // add a break to get the values down from the number
- e.Cell.Controls.Add(new LiteralControl("<br /><br />"));
- for (int i = 0; i < rowsService.Length; i++)
- {
- // Get the value of the new category
- string newCategory = rowsService[i][0].ToString();
- if (category == newCategory)
- {
- // nada
- }
- else
- {
- e.Cell.Controls.Add(new LiteralControl("<br />"));
- Label labelCategory = new Label();
- labelCategory.Text = newCategory;
- labelCategory.Font.Name = "Verdana";
- labelCategory.Font.Size = 9;
- labelCategory.Font.Bold = false;
- labelCategory.Width = 120;
- labelCategory.Height = 15;
- labelCategory.BackColor = System.Drawing.Color.LightSkyBlue;
- e.Cell.Controls.Add(labelCategory);
- e.Cell.Controls.Add(new LiteralControl("<br />"));
- }
- // add a checkbox with the appropriate values...
- CheckBox checkbox = new CheckBox();
- checkbox.ID = rowsService[i][2].ToString() + "_" + rowsService[i][3].ToString();
- checkbox.Text = "";
- HyperLink hyperlink = new HyperLink();
- hyperlink.Text = rowsService[i][1].ToString() + " @ " + String.Format("{0:c}", rowsService[i][5]);
- hyperlink.NavigateUrl = "~/ProductDetails.aspx?ProductID="+rowsService[i][2].ToString();
- e.Cell.Controls.Add(checkbox);
- e.Cell.Controls.Add(hyperlink);
- e.Cell.Controls.Add(new LiteralControl("<br />"));
- // reset the category value
- category = newCategory;
- }
- }
- e.Cell.BackColor = System.Drawing.Color.LightGoldenrodYellow;
- }
- else
- {
- e.Cell.Width = 25;
- }
- }
- }