473,761 Members | 7,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox controls inside a Calendar control

1 New Member
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 1743

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

Similar topics

5
4319
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 control then is invisible. How do I make the calendar control pop up over other control in a asp.net c# environment? Charles
6
1787
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 development environment where rather than having each developer running a local copy of a website, they can make changes simultaneously to a central web server without stepping on each other's toes as far as compilation is concerned. ANYWAY, this is fine...
3
2649
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 and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created I have to set
0
2406
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 CheckBox Programmatically" in my code. I have changed it to use a OLDDB.DBReader to populate the datagrid and for the databinding. It works perfectly - also when using the edit-mode in the datagrid.
1
1281
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 (declaratively), and the calendar has no properties explicitly set (declaratively or otherwise). These controls are placed on the aspx page declaratively. The point so far is that this is the absolute minimal aspx page with the simplest possible implementation...
10
2446
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 control in a datagrid? Now I have a Select column but the problem is that the user needs to select more than one record and send them all to print, instead of being one by one like is now with the Select column. Another question, is it possible to...
1
4510
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 checkbox and I can't get it to default to checked. I tried radiobuttons and experienced the same result.. can't start them as checked. The really frustrating thing is that I set the attributes of other input controls in the Init() with no problem. ...
1
3780
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 say's "process". I want to LOOP through each datalist entry and see if the user checked the check box. Simple. I wrote the code, but the checked value is ALWAYS False. Any ideas? Here's the code...
1
6017
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 check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in a different event...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.