have a web form using Asp.net 2.0 with vb.net. I have two date fields on the form but I would like to validate them before my gridview uses them as parameters. I am using a Dataset for the source of the gridview and two parameters called StartDate and EndDate.

Basically in the code I am setting the values of the fields to the current date at runtime. Also the date fields in the SQL Server table are datetime and I only want the user to have to enter the date and it would grab all records within that date range regardless of the time. When the user enters the two dates and clicks a button on the form I need it to reset the parameters to the enter dates and refresh the data.

Any Ideas how I could get this to work?

Here is the code:

Code:
Partial Class DispatchRequestList
    Inherits System.Web.UI.Page

   
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtStartDate.Text = Today()
        txtEndDate.Text = Today()
    End Sub

    
    Protected Sub objRequests_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles objRequests.Selecting
        Dim paramFrom As New Parameter
        Dim paramTo As New Parameter
        paramFrom.Name = "@Startdate"
        paramTo.Name = "@Enddate"
        paramFrom.Type = TypeCode.DateTime
        paramTo.Type = TypeCode.DateTime
        paramFrom.DefaultValue = txtStartDate.Text
        paramTo.DefaultValue = txtEndDate.Text
        objRequests.SelectParameters.Add(paramFrom)
        objRequests.SelectParameters.Add(paramTo)

    End Sub
End Class
Here is the ASP.net page:

Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DispatchRequestList.aspx.vb" Inherits="DispatchRequestList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body bgcolor="#99ccff">
    <form id="form1" runat="server">
    <div>
        <h1 style="text-align: center">
            <span style="color: #3300ff">Dispatch Request List</span></h1>
        <p>
            &nbsp;</p>
        <p>
            <span style="color: #3300ff">
                <asp:Label ID="Label1" runat="server" Text="Start Date" Width="105px"></asp:Label>
                <asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox></span></p>
        <p>
            <span style="color: #3300ff">
                <asp:Label ID="Label2" runat="server" Text="End Date" Width="105px"></asp:Label>
                <asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox></span></p>
        <p>
            <span style="color: #3300ff">
                <asp:Button ID="btnRecords" runat="server" Text="Show Records" /></span></p>
        <p>
            &nbsp;</p>
        <p>
            <span style="color: #3300ff">
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="objRequests" HorizontalAlign="Center">
                    <Columns>
                        <asp:BoundField DataField="RequestDate" HeaderText="Request Date" SortExpression="RequestDate" />
                        <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" SortExpression="Name" />
                        <asp:BoundField DataField="EquipmentType" HeaderText="Equip Type" SortExpression="EquipmentType" />
                        <asp:BoundField DataField="PickupDelivery" HeaderText="Pickup/Delivery" SortExpression="PickupDelivery" />
                        <asp:BoundField DataField="Job" HeaderText="Job" SortExpression="Job" />
                        <asp:BoundField DataField="JobSuffix" HeaderText="Suffix" SortExpression="JobSuffix" />
                        <asp:BoundField DataField="WorkCenter_Desc" HeaderText="Work Ctr" ReadOnly="True"
                            SortExpression="WorkCenter_Desc" />
                        <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                        <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
                        <asp:BoundField DataField="AssignedDate" HeaderText="Assigned Date" SortExpression="AssignedDate" />
                        <asp:BoundField DataField="CompleteDate" HeaderText="Complete Date" SortExpression="CompleteDate" />
                    </Columns>
                </asp:GridView>
                <asp:ObjectDataSource ID="objRequests" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="GetRequestsByRequestDate" TypeName="GAI_DataAccessLayerTableAdapters.disp_DispatchRequestTableAdapter">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtStartDate" Name="Startdate" PropertyName="Text"
                            Type="DateTime" />
                        <asp:ControlParameter ControlID="txtEndDate" Name="Enddate" PropertyName="Text" Type="DateTime" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </span>
        </p>
    </div>
    </form>
</body>
</html>