I need to construct a DateTime object with the date coming from a calendar and the hours/mins/am-pm coming from three drop down lists.
The DateTime is being inserted into a DB as a regular DateTime SQL Server DB type. I’ll use something like string dt = String.Format(“{0:g}”, DateTime.Now); to parse it when grabbing it from the DB.
I just need to find an elegant way to construct the DateTime object for the DB insertion.
Why not use the standard
DateTimeconstructor overload detailed here (MSDN).Where you grab the
year,month,dayfrom your calendar, and thehour,minute,secondvalues from parsed drop down values.