This is a migrated thread and some comments may be shown as answers.

How do I get the first date shown and the last date shown

3 Answers 122 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
LCJ
Top achievements
Rank 1
LCJ asked on 05 Feb 2009, 06:46 PM
I cannot seem to get the first date shown and the last date shown.  There are two property with the term "display" (sorry, do not have VS open to tell you the exact properties) and that specify start and end dates.  I want to query the database and pull all values between these two dates so that I can color the cells accordingly (light for fewer things, dark for more things, any direction on this would be welcome also but I haven't looked at it yet).

For some reason I don't seem to be able to get any values back from these properties.  Are these the right properties?

3 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 06 Feb 2009, 06:36 PM
Hey LJC,

I was curious so I had to check this out, and you're definitely right that these come up as nulls.  One thing I noticed though is that when you try to set the date, looking at the items in debug mode the DisplayStartDate/DisplayEndDate will show the correct value, but this gets thrown to prevent further operation:

Invalid DisplayDateStart value.
Parameter name: sender

So I am guessing there is an incorrect reference somewhere?  Hopefully this can be remedied for Q1, the Telerik calendar is so much nicer to look at than the default MS one. :)

P.S., I checked and this does work on the RadDatePicker, just not on Calendar.  Also, DisplayDateEnd works fine, but DisplayDateStart is the one with the problem on both.
0
Jyoti
Top achievements
Rank 1
answered on 18 Jul 2011, 08:11 PM
Is Displaystartdate is working fine in Raddatepicker? I am getting an error if i want to set the value dynamically. Displayenddate is working fine.
0
Pana
Telerik team
answered on 22 Jul 2011, 08:12 AM
Hello Jyoti,

Problem is RadCalendar does not coerce its DisplayDateStart, DisplayDate, DisplayDateEnd properly. For example the following code fails:

calendar.DisplayDate = DateTime.Today.Date.AddDays(3);
calendar.DisplayDateStart = DateTime.Today.Date.AddDays(4);
calendar.DisplayDateEnd = DateTime.Today.Date.AddDays(20);

while the following works:

calendar.DisplayDate = DateTime.Today.Date.AddDays(3);
calendar.DisplayDateStart = DateTime.Today.Date.AddDays(2);
calendar.DisplayDateEnd = DateTime.Today.Date.AddDays(20);

You could take for granted the default DisplayDateStart is smallest possible DateTime in the calendar, while the DisplayDateEnd is the last. Setting the DisplayDateStart to a day bigger than the DisplayDate will throw an exception. So as a workaround you could first set the DisplayDate to the value you desire and after set the DisplayDateStart and DisplayDateEnd.

If you are about to change these values more than once you could try to first clear the old Start and End values by setting the Start to a really small date and the End to really large (like the years 0001 and 3000), set the DisplayDate and then set the DisplayStartDate and DisplayEndDate to the real values.

I know this workaround is ugly but you could use it until we fix the value coercing.

Greetings,
Pana
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Calendar
Asked by
LCJ
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
Jyoti
Top achievements
Rank 1
Pana
Telerik team
Share this question
or