asked on
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[] rowsExisting = dtExisting.Select("LunchDate = '" + daDate + "'");
DataRow[] rowsService = dtService.Select("ServiceDate = '" + daDate + "'", "CategoryName ASC, ProductName DESC");
if (rowsExisting.Length == 0 && rowsService.Length == 0)
{
Label labelNone = new Label();
labelNone.ForeColor = System.Drawing.Color.Black;
labelNone.Font.Name = "Verdana";
labelNone.Font.Size = FontUnit.Point(11);
labelNone.Font.Bold = true;
labelNone.Text = "No Lunches Available";
e.Cell.Controls.Add(labelNone);
}
// 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);
}
// Create a check box control to use for ordering of each returned row.
if (rowsService.Length > 0)
{
CheckBoxList checkboxlist = new CheckBoxList();
checkboxlist.RepeatColumns = 1;
checkboxlist.RepeatDirection = RepeatDirection.Vertical;
checkboxlist.ID = rowsService[0][2].ToString();
string category = "";
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
{
checkboxlist.Items.Add(new ListItem(newCategory, newCategory, false));
}
checkboxlist.Items.Add(new ListItem(rowsService[i][1].ToString() + " @ " + String.Format("{0:c}", rowsService[i][5]), rowsService[i][3].ToString()));
category = newCategory;
//CheckBox checkbox = new CheckBox();
//checkbox.ID = rowsService[i][2].ToString() + "_" + rowsService[i][3].ToString();
//checkbox.Text = rowsService[i][1].ToString() + " @ " + String.Format("{0:c}", rowsService[i][5]);
//e.Cell.Controls.Add(checkbox);
//Response.Write("<br />");
}
// add the list to the cell
e.Cell.Controls.Add(checkboxlist);
}
e.Cell.BackColor = System.Drawing.Color.LightGoldenrodYellow;