I have a page with 4 text boxes: Start Date, Start Time, End Date, End Time.
My database has a table with 2 fields: StartDate_Time, EndDate_Time. I'm
trying to set the value of my select parameters to a combination of date and
time. I thought I was on the right path with this code:
ObjectDataSource1.SelectParameters("StartDate").DefaultValue =
dStartDateTime.ToUniversalTime
However, when I check the date values in the method, the date is being sent
without the time. Where am I going wrong?
Object Data Source:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAvailableRooms" TypeName="RoomsAvailable">
<SelectParameters>
<asp:ControlParameter ControlID="txtEndDate" Name="EndDate"
PropertyName="Text" Type="DateTime" />
<asp:ControlParameter ControlID="txtStartDate" Name="StartDate"
PropertyName="Text" Type="DateTime" />
</SelectParameters>
</asp:ObjectDataSource>
Method From Business Logic Layer
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, True)> _
Public Function GetAvailableRooms(ByVal EndDate As Nullable(Of DateTime),
ByVal StartDate As Nullable(Of DateTime)) As
RoomsDataSet.RoomsAvailableDataTable
Return Adapter.GetAvailableRooms(EndDate, StartDate)
End Function
Button click event:
Dim sStartDateTime As String = txtStartDate.Text & " " & txtStartTime.Text
Dim sEndDateTime As String = txtEndDate.Text & " " & txtEndTime.Text
Dim dStartDateTime As DateTime = DateTime.Parse(sStartDateTime)
Dim dEndDateTime As DateTime = DateTime.Parse(sEndDateTime)
ObjectDataSource1.SelectParameters("StartDate").DefaultValue =
dStartDateTime.ToUniversalTime
ObjectDataSource1.SelectParameters("EndDate").DefaultValue =