I have CalendarView on two pages.
First page is used to add records to calendar by assigning the selected date to the database record.
Second page is used to show all records assigned to the selected date.
Now, when on the first page I assign date to the product by clicking the date manually, on the second page product is shown correctly when selected date that corresponds to the products date.
However, when on the first page I add dates to the products programmatically, on the second page, these products are shown one day before than they should.
I have no idea what is happening. I will post code if you want to check something.
THe problem is strange, becaue on one calendar these automatically added dates are shown for example on 5th April, but on the second calendar they are listed under 4th April.
Is that the globalization of two calendars problem?
Locale(globalization ) would be a potential problem. But having code would help us to provide you more info.
I have managed to resolve the problem. It was in deed issue with DateTimeOffset/DateTime values.
I changed every instance of Date I found in the code by appending it with
.LocalDateTime
.
This way I got the correct local date of each DateTimeOffset object and data is added to/ pulled from the Calendar correctly.
Related
Im writing a hotel booking system with VS2012 which uses ms sql and in the booking i have two datetimepicker controls. When i select a date in the first one the date automatically gets transfered to the second datetimepicker. I now want when the user opens up the second datetimepicker not being able to select a date that is before the first date from the first datetimepicker. I dont want to use if method displaying a message i just want the dates to be "greyed" out.
Is that possible and how?
*edit (screenshot of how i would like it to be viewed or similar http://i43.tinypic.com/2zpimvs.jpg )
*edit2: its not the control(dateTimePicker2) it self i want to grey out, its the dates inside it that is smaller then the date selected in dateTimePicker1. The screenshot provided is in the area of what im looking for.
You could try this:
DateTimePicker2.MinValue = Convert.toDateTime(DateTimePicker1.SelectedDate);
EDIT
Standard controls don't support the grey-out of a datetimepicker. If you want to do this, you need to subclass the datetimepicker or look at a premade control like a DateEdit from devexpress (i think they even have free controls).
Change the second datepicker MinDate to first DatePicker selected date .. like below ..
rdpDatePicker2.MinDate = rdpDatePicker1.SelectedDate.Value;
I have to display data from a table on a gridview in an asp.net webform application. When the page loads, it should show a 30 day worth of data based upon the createddate field in the table. Above the grid, I have two date picker controls, which can be used to select a date range; when a date range is selected, it should show data based upon the dates. I am restricted to use only linq-to-sql for data access. One option is to select all data from the table, when the page loads, then display 30 day's worth of data. Filter the data if date range is selected, subsequent to page load. However the problem is that it may bring too much data. Please let me know a better option.
Thanks
Filter in the database - which is basically how most of Linq-to-SQL will work anyway. You just need to write the where clause using your date range.
A feature of a forms based application I am developing allows the user to search through a history of records.
The user can search by name, by number, and between dates, and populate the results in a datagridview control.
However, as the form will be used to search for previous records. The ability for the user to select future dates is not required.
Is there a way to prevent the user from selecting future dates, or even grey the future dates out?
You can try with code based on MaxDate property
yourControl.MaxDate = DateTime.Today;
Link : http://msdn.microsoft.com/fr-fr/library/system.windows.forms.datetimepicker.maxdate.aspx
You can use the DateTimePicker.MaxDate Property:
DateTimePicker.MaxDate Property: Gets or sets the maximum date and time that can be selected in the control.
Please try:
dateTimePicker.MaxDate = DateTime.Now;
Setting the MaxDate property will hide all dates after the specified date, and will not allow dates to be entered that are greater than that date.
See http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.maxdate.aspx for details.
I have an ASP.NET 4 calendar display problem. I want to programmatically set the calendar. So, I put this code in the void Page_Load(object sender, EventArgs e) function:
Calendar1.SelectedDate = DateTime.Parse("2011-07-25");
it works fine. But, it displays the current month of the calendar (August) instead of the date I selected (July). I have to select back one month to see the date that I programmatically assigned.
What should i do?
Thanks!
You need to set the VisibleDate property to the month that you want it to show =)
There is a gotcha that you should be aware of.
If you set the selected date to DateTime.Now or something based on it such as DateTime.Now.AddYears(1) then the selected date will not be highlighted in the calendar even though it is selected.
You need to remove the time component using DateTime.Now.Date so that the calendar can do the comparison correctly when rendering. It took me a bit of debugging in the DayRenderEventHandler to figure that out.
I hope that somebody finds it useful.
I am accessing RepeatForUnit to manage "Repeats" in Lotus Notes.
String RepeatForUnit = (string)((object[])docCalendarDoc.GetItemValue("RepeatForUnit"))[0];
Initially i was getting "D" for Daily event, "W" for Weekly and "Y" for Yearly.
But now properties field not showing any of this value even after adding Repeat in calendar.It is not visible in Properties list of Lotus Notes Calendar and showing "" (black entry) for above code.
I am not getting why this is happening.Can anybody help me out in this?
I am not sure of the logic, but Notes sometimes does not include the RepeatUnit, RepeatForUnit, etc fields and insteads treats the repeating calendar entry as a "custom" repeat, which uses only the "RepeatInstanceDates" item (which is a multi-values date datatype). Depending on what your code is doing, perhaps it can also check this item.
A listing of the "repeating calendar entry" - related items can be found here.