We're creating a timesheets application.
We're using a bound DataGridView to display the Task, StartTime and EndTime columns. The StartTime and EndTime are saved as datetimes in the bound SQL table.
The StartTime and EndTime have their CellTemplate defined as follows, so that they only show the Time part:
colStartTime.CellTemplate.Style.Format = "HH:mm";
colEndTime.CellTemplate.Style.Format = "HH:mm";
We only want to allow the user to change the start and end times for each task on the timesheet - because the Date is set at the timesheet level so is fixed.
However the problem is that the StartTime and EndTime have Today's date even if we are editing a timesheet for a day in the past. i.e. I edit yesterday's timesheet and change it so that I started Task1 at 10:30. The row gets updated fine but instead of using yesterday's date the DateTime has the start time as today at 10:30.
What's the correct way to deal with this? Override some databinding event to check the date and overwrite it? Or is there a CellTemplate property I can set?
Thanks