Calendar control help

Results 1 to 2 of 2

Thread: Calendar control help

  1. #1
    Join Date
    Dec 1969

    Default Calendar control help

    I have created a calendar control for a scheduling system. The schedule is done by week and saved with the date for the Monday of that week. Another table holds a template for each employee for a six-week rotation. However, their manager needs to be able to make changes daily "on the fly". What I need to be able to do (in code-behind) is check what date they&#039;ve clicked on (I know how to do that) and then find the date of Monday in that same week so I can grab the correct schedule from the database. <BR><BR>Can anyone help?

  2. #2
    Join Date
    Dec 1969

    Default RE: Calendar control help

    There is no &#039;pretty&#039; way to do this due to the date.DayofWeek is an enumeration. I would recommend a method like:<BR><BR>public static DateTime getMonday(DateTime pDate)<BR>{<BR>switch (pDate.DayOfWeek)<BR>{<BR> case System.DayOfWeek.Sunday:<BR> return pDate.addDays(1);<BR> break;<BR> case System.DayOfWeek.Monday:<BR> return pDate;<BR> break;<BR> case System.DayOfWeek.Tuesday:<BR> return pDate.addDays(-1);<BR> break;<BR>}<BR>}<BR><BR>Not pretty but effective:-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts