473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Checkbox controls inside a Calendar control

Hi all--

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
  1. protected void LunchCalendar_DayRender(object sender, DayRenderEventArgs e)
  2.     {
  3.         {
  4.             //if (e.Day.IsWeekend)
  5.             //{ 
  6.             //    e.Cell.Visible = false;
  7.             //}
  8.  
  9.             DateTime daDate = DateTime.Parse(e.Day.Date.ToString());
  10.  
  11.             if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
  12.             {
  13.                 // Set the width as it will have data
  14.                 e.Cell.Width = 140;
  15.  
  16.                 // DataRow[] rowTest = dtService.Select(string.Format("[ServiceDate] = '{0}'", e.Day.Date));
  17.                 DataRow[] rowsExisting = dtExisting.Select("LunchDate = '" + daDate + "'");
  18.                 DataRow[] rowsService = dtService.Select("ServiceDate = '" + daDate + "'", "CategoryName ASC, ProductName DESC");
  19.  
  20.                 if (rowsExisting.Length == 0 && rowsService.Length == 0)
  21.                 {
  22.                     e.Cell.Controls.Add(new LiteralControl("<br /><br />"));
  23.                     e.Cell.Controls.Add(new LiteralControl("<br /><br /><center>"));
  24.                     Label labelNone = new Label();
  25.                     labelNone.ForeColor = System.Drawing.Color.Black;
  26.                     labelNone.Font.Name = "Verdana";
  27.                     labelNone.Font.Size = FontUnit.Point(10);
  28.                     labelNone.Font.Bold = true;
  29.                     labelNone.Text = "No Lunches Available";
  30.                     e.Cell.Controls.Add(labelNone);
  31.                     e.Cell.Controls.Add(new LiteralControl("</center>"));
  32.                 }
  33.  
  34.                 // Create a label to print ordered info of each returned row.
  35.                 for (int i = 0; i < rowsExisting.Length; i++)
  36.                 {
  37.                     Label label = new Label();
  38.                     label.Text = rowsExisting[i][0].ToString() + " ea. " + rowsExisting[i][3].ToString();
  39.                     e.Cell.Controls.Add(label);
  40.                     e.Cell.Controls.Add(new LiteralControl("<br />"));
  41.                 }
  42.  
  43.                 // Create a check box control to use for ordering of each returned row.
  44.                 if (rowsService.Length > 0)
  45.                 {
  46.                     string category = "";
  47.                     // add a break to get the values down from the number
  48.                     e.Cell.Controls.Add(new LiteralControl("<br /><br />"));
  49.  
  50.                     for (int i = 0; i < rowsService.Length; i++)
  51.                     {
  52.                         // Get the value of the new category
  53.                         string newCategory = rowsService[i][0].ToString();
  54.  
  55.                         if (category == newCategory)
  56.                         {
  57.                             // nada
  58.                         }
  59.                         else
  60.                         {
  61.                             e.Cell.Controls.Add(new LiteralControl("<br />"));
  62.                             Label labelCategory = new Label();
  63.                             labelCategory.Text = newCategory;
  64.                             labelCategory.Font.Name = "Verdana";
  65.                             labelCategory.Font.Size = 9;
  66.                             labelCategory.Font.Bold = false;
  67.                             labelCategory.Width = 120;
  68.                             labelCategory.Height = 15;
  69.                             labelCategory.BackColor = System.Drawing.Color.LightSkyBlue;
  70.                             e.Cell.Controls.Add(labelCategory);
  71.                             e.Cell.Controls.Add(new LiteralControl("<br />"));
  72.                         }
  73.  
  74.                         // add a checkbox with the appropriate values...
  75.                         CheckBox checkbox = new CheckBox();
  76.                         checkbox.ID = rowsService[i][2].ToString() + "_" + rowsService[i][3].ToString();
  77.                         checkbox.Text = "";
  78.                         HyperLink hyperlink = new HyperLink();
  79.                         hyperlink.Text = rowsService[i][1].ToString() + " @ " + String.Format("{0:c}", rowsService[i][5]);
  80.                         hyperlink.NavigateUrl = "~/ProductDetails.aspx?ProductID="+rowsService[i][2].ToString();
  81.                         e.Cell.Controls.Add(checkbox);
  82.                         e.Cell.Controls.Add(hyperlink);
  83.                         e.Cell.Controls.Add(new LiteralControl("<br />"));
  84.                         // reset the category value
  85.                         category = newCategory;
  86.  
  87.                     }
  88.  
  89.                 }
  90.  
  91.                 e.Cell.BackColor = System.Drawing.Color.LightGoldenrodYellow;
  92.             }
  93.             else
  94.             {
  95.                 e.Cell.Width = 25;
  96.             }
  97.         }
  98.     }
Thanks for your help.
Jul 21 '08 #1
0 1708

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Charles | last post by:
Hello, I would like for my users to have a calendar control only when needed. IE button click for the control to appear and then once the date is selected. Populate a text box and the calendar...
6
by: Nehal Shah | last post by:
I've read that in the Page Directive of an aspx page, changing the CodeBehind attribute to Src saves you from having to compile the page before refreshing. This is preferable in a large...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
1
by: Guadala Harry | last post by:
I have a very simple aspx page (no code-behind logic) that hosts two 3rd party controls (a dynamic menu and a calendar). The dynamic menu has the bare minimum number of properties set...
10
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
1
by: VB Programmer | last post by:
Simple: I have a datalist that is holding a bunch of job opportunities. Beside each opp (in the item template) there's a checkbox that says "apply". After the datalist there's a button that...
1
by: iderocks | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and when I...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.