I am trying to search for records in my gridview that are between 2 dates, and I can't figure out what I'm doing wrong. When I search by Description, I click on the Description in the dropdownlist and the records filter right away. I enter the 2 dates, and it does not filter. Can you please tell me what I am doing wrong? Here is my code:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/site.master" CodeBehind="TimeOffAllByUser.aspx.vb" Inherits="timework.TimeOffAllByUser" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"><asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None" style="margin-right: 0px"
AllowPaging="True" AllowSorting="True"><AlternatingRowStyle BackColor="White" ForeColor="#284775" /><Columns><asp:BoundField DataField="EmployeeName" HeaderText="Name"
ItemStyle-Width="150px"
SortExpression="EmployeeName" /><asp:BoundField DataField="BeginDateOff" HeaderText="Begin Date"
DataFormatString="{0:d}"
SortExpression="BeginDateOff" /><asp:BoundField DataField="EndDateOff" HeaderText="End Date"
DataFormatString="{0:d}"
SortExpression="EndDateOff" /><asp:CheckBoxField DataField="AllDay_YesNo" HeaderText="All Day?"
ItemStyle-HorizontalAlign="Center"
SortExpression="AllDay_YesNo" /><asp:BoundField DataField="BeginTimeOff" HeaderText="Begin Time"
DataFormatString="{0:t}"
SortExpression="BeginTimeOff" /><asp:BoundField DataField="EndTimeOff" HeaderText="End Time"
DataFormatString="{0:t}"
SortExpression="EndTimeOff" /><asp:CheckBoxField DataField="Approved" HeaderText="Approved"
ItemStyle-HorizontalAlign="Center"
SortExpression="Approved" /><asp:BoundField DataField="Description" HeaderText="Reason"
ItemStyle-Width="150px"
SortExpression="Description" /></Columns><EditRowStyle BackColor="#999999" /><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><SortedAscendingCellStyle BackColor="#E9E7E2" /><SortedAscendingHeaderStyle BackColor="#506C8C" /><SortedDescendingCellStyle BackColor="#FFFDF8" /><SortedDescendingHeaderStyle BackColor="#6F8DAE" /></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TimeSQLConnectionString1 %>"
SelectCommand="SELECT tblWorkHours.EmployeeName, tblWorkHours.BeginDateOff, tblWorkHours.EndDateOff, tblWorkHours.AllDay_YesNo, tblWorkHours.BeginTimeOff, tblWorkHours.EndTimeOff, tblWorkHours.Approved, tblCodesWork.Description, tblEmployees.Login FROM tblWorkHours INNER JOIN tblCodesWork ON tblWorkHours.WorkCode = tblCodesWork.WorkCodeID INNER JOIN tblEmployees ON tblWorkHours.Employee = tblEmployees.EmployeeID WHERE (tblEmployees.Login = @username) ORDER BY tblWorkHours.BeginDateOff DESC"
OnSelecting="SqlDataSource1_Selecting"
FilterExpression="Description='{0}'"><SelectParameters><asp:QueryStringParameter Name="username" /></SelectParameters><FilterParameters><asp:ControlParameter Name="Description" ControlId="fltrdesc" PropertyName="SelectedValue"/></FilterParameters></asp:SqlDataSource>
Time Off Reason: <asp:DropDownList ID="fltrdesc" runat="server"
Height="26px" Width="135px" style="text-align: center"
DataSourceID="SqlDataSource2" DataTextField="Description"
DataValueField="Description" AutoPostBack="True" ></asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:TimeSQLConnectionString1 %>"
SelectCommand="SELECT [Description] FROM [tblCodesWork] ORDER BY [Description]"></asp:SqlDataSource> <asp:ToolkitScriptManager ID="toolkitScriptManager" runat="server" /><br />
Search for Time Off For <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox><ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server"
Enabled="True" TargetControlID="TextBox1"/> <asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"></asp:TextBox><ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server"
Enabled="True" TargetControlID="TextBox2"/><asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:TimeSQLConnectionString1 %>"
SelectCommand="SELECT tblWorkHours.EmployeeName, tblWorkHours.BeginDateOff, tblWorkHours.EndDateOff, tblWorkHours.AllDay_YesNo, tblWorkHours.BeginTimeOff, blWorkHours.EndTimeOff, tblWorkHours.Approved, tblCodesWork.Description, tblEmployees.Login
FROM tblWorkHours INNER JOIN tblCodesWork ON tblWorkHours.WorkCode = tblCodesWork.WorkCodeID INNER JOIN tblEmployees
ON tblWorkHours.Employee = tblEmployees.EmployeeID
WHERE (tblEmployees.Login = @username) and (CAST(BeginDateOff as Date) >= TextBox1) AND (CAST(EndDateOff as Date) <= TextBox2)
ORDER BY tblWorkHours.BeginDateOff DESC"
OnSelecting="SqlDataSource1_Selecting"
FilterExpression="BeginDateOff='{0}' and EndDateOff='{1}"><SelectParameters><asp:QueryStringParameter Name="username" /></SelectParameters><FilterParameters><asp:ControlParameter Name="BeginDateOff" ControlId="TextBox1" Type="DateTime" PropertyName="Text"/><asp:ControlParameter Name="EndDateOff" ControlID="TextBox2" Type="DateTime" PropertyName="Text"/></FilterParameters></asp:SqlDataSource> <asp:Button ID="btnClear" runat="server" onclick="btnClear_Click" Text="Clear" /><br /> </asp:Content>Thanks in advance!