I have a databound DataGridView. The data source is a typed data set with a table containing two DateTime
columns (BeginTimeStamp
and EndTimeStamp
). I read and write the data to an SQL Server 2005 database using the typed data set's Update
command.
The user must enter a date into each of the two columns, which I enforce using the CellValidating
and RowValidating
events. However, I also need to make sure that the following two rules apply:
- The time value for the
BeginDate
column must always be 00:00:00 - The time value for the
EndDate
column must always be 23:59:59 (or 11:59:59 pm if you like)
As I do not want the user to enter the 23:59:59 all the time, I'd like to somehow change the user's inputs according to 1. and 2. in my code.
Where and how would I do that?
EDIT
Sorry in case I was unclear. The user may enter any date part, however, the time part is fixed at midnight for the BeginTimeStamp
and 23:59:59 for the EndTimeStamp
.
Example:
The user enters 2009/01/01 01:00:00pm as BeginTimeStamp
. My application should change this to 2009/01/01 00:00:00.
The user enters 2009/01/31 01:00:00pm as EndTimeStamp
. My application should change this to 2009/01/31 23:59:59.