Hey,

I wanted to generate a report (GenReport.aspx) containing the list of GridView items filtered from the entered data from report.aspx. When I was debugging, I selected the data I wanted to filter, but it shows me all the data on the table instead of the data filtered on the table.

GenReport.aspx.cs

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn() { ColumnName = "AppTypeName", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "name", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "designation", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "OfficeName", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "floorNo", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "DeptName", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "projectType", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "emailDiversionType", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "IntAccess", DataType = typeof(bool) });
                dt.Columns.Add(new DataColumn() { ColumnName = "nsf", DataType = typeof(bool) });
                dt.Columns.Add(new DataColumn() { ColumnName = "loanComp", DataType = typeof(bool) });
                dt.Columns.Add(new DataColumn() { ColumnName = "Date", DataType = typeof(DateTime) });

                string AppTypeName = Request.QueryString["status"];
                string name = Request.QueryString["name"];
                string designation = Request.QueryString["designation"];
                string OfficeName = Request.QueryString["office"];
                string floorNo = Request.QueryString["floor"];
                string DeptName = Request.QueryString["dept"];
                string projectType = Request.QueryString["project"];
                string emailDiversionType = Request.QueryString["emailDiv"];
                bool IntAccess = false;
                bool nsf = false;
                bool loanComp = false;

                if (Request.Form["IA"] != null && Request.Form["IA"] == "true")
                {
                    IntAccess = true;
                }
                if (Request.Form["NSF"] != null && Request.Form["NSF"] == "true")
                {
                    nsf = true;
                }
                if (Request.Form["LC"] != null && Request.Form["LC"] == "true")
                {
                    loanComp = true;
                }

                dt.Rows.Add(AppTypeName, name, designation, OfficeName, floorNo, DeptName, projectType, emailDiversionType, IntAccess, nsf, loanComp, DateTime.Now);
                // I have made the Date as DateTime.Now

                FormView1.DataSource = dt;
                FormView1.DataBind();
            }
        }

GenReport.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GenReport.aspx.cs" Inherits="IT_application_form_v4.admin.GenReport" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            text-decoration: underline;
        }
        .auto-style4 {
            width: 20px;
        }
        .auto-style5 {
            width: 87px;
        }
        .auto-style6 {
            width: 233px;
        }
        .auto-style7 {
            width: 255px;
        }
        .auto-style8 {
            width: 171px;
        }
        .auto-style9 {
            width: 230px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="PrintButton" runat="server" Text="Print" OnClientClick="javascript:window.print();"/>

    <div align="center">
    <!--<asp:Image ID="mmcGamudaLogo" runat="server" Height="94px" ImageAlign="Middle" ImageUrl="img/mmc-gamuda logo large.png" style="text-align: center" /><br />-->
    <strong>APPLICANT LIST</strong>
    </div>

    <div class="panel panel-default">
        <div class="panel-body">
            <asp:FormView ID="FormView1" runat="server">
            <ItemTemplate>
                <strong>Printed On: </strong>
                <asp:Label ID="printDateTime" runat="server" Text='<%# Bind("Date") %>'></asp:Label>
                <br />
                <strong>Printed By: </strong>

                <hr />

                <span class="auto-style1"><strong>FILTERS:</strong></span><br />
                <table style="width: 100%;">
                    <tr>
                        <td class="auto-style8"><b>Status:</b></td>
                        <td class="auto-style9">
                            <asp:Label ID="StatusLbl" runat="server" Text='<%# Eval("AppTypeName") %>'></asp:Label>
                        </td>
                        <td class="auto-style4" rowspan="3">&nbsp;</td>
                        <td class="auto-style5"><b>Office:</b></td>
                        <td class="auto-style6">
                            <asp:Label ID="OfficeLbl" runat="server" Text='<%# Eval("OfficeName") %>'></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style8"><b>Name (starts with):</b></td>
                        <td class="auto-style9">
                            <asp:Label ID="nameLbl" runat="server" Text='<%# Eval("name") %>'></asp:Label>
                        </td>
                        <td class="auto-style5"><b>Floor:</b></td>
                        <td class="auto-style6">
                            <asp:Label ID="FloorLbl" runat="server" Text='<%# Eval("floorNo") %>'></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style8"><b>Designation (starts with):</b></td>
                        <td class="auto-style9">
                            <asp:Label ID="designationLbl" runat="server" Text='<%# Eval("designation") %>'></asp:Label>
                        </td>
                        <td class="auto-style5"><b>Department:</b></td>
                        <td class="auto-style6">
                            <asp:Label ID="DeptLbl" runat="server" Text='<%# Eval("DeptName") %>'></asp:Label>
                        </td>
                    </tr>
                </table>
                <hr />
                <b>Project: </b>
                <asp:Label ID="ProjectLbl" runat="server" Text='<%# Eval("projectType") %>'></asp:Label>

                <br />
                <strong>E-mail Diversion:</strong>
                <asp:Label ID="emailDiversionLbl" runat="server" Text='<%# Eval("emailDiversionType") %>'></asp:Label>
                <hr />
                <table style="width: 100%;">
                    <tr>
                        <td><b>Internet Access: </b>
                            <asp:CheckBox ID="IntAccessCheckBox" runat="server" Enabled="false" Checked='<%# Eval("IntAccess") %>' /></td>
                        <td><b>Network Shared Folder: </b>
                            <asp:CheckBox ID="nsfCheckBox" runat="server" Enabled="false" Checked='<%# Eval("nsf") %>' /></td>
                        <td><b>Loan Computer: </b>
                            <asp:CheckBox ID="loanCompCheckBox" runat="server" Enabled="false" Checked='<%# Eval("loanComp") %>' /></td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:FormView>
        </div>
    </div>
    <br />
    <div>
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="AppTypeName" HeaderText="Status" SortExpression="AppTypeName" />
                <asp:BoundField DataField="name" HeaderText="Name" SortExpression="name" />
                <asp:BoundField DataField="designation" HeaderText="Designation" SortExpression="designation" />
                <asp:BoundField DataField="OfficeName" HeaderText="Office" SortExpression="OfficeName" />
                <asp:BoundField DataField="floorNo" HeaderText="Floor" SortExpression="floorNo" />
                <asp:BoundField DataField="DeptName" HeaderText="Dept" SortExpression="DeptName" />
                <asp:BoundField DataField="projectType" HeaderText="Project" SortExpression="projectType" />
                <asp:CheckBoxField DataField="EmailID" HeaderText="E-mail ID" SortExpression="EmailID" />
                <asp:CheckBoxField DataField="EmailGroup" HeaderText="E-mail Group" SortExpression="EmailGroup" />
                <asp:BoundField DataField="EmailGroupName" HeaderText="E-mail Group Name" SortExpression="EmailGroupName" />
                <asp:BoundField DataField="emailDiversionType" HeaderText="E-mail Div" SortExpression="emailDiversionType" />
                <asp:BoundField DataField="emailDiversionAdd" HeaderText="E-mail Div ID" SortExpression="emailDiversionAdd" />
                <asp:CheckBoxField DataField="IntAccess" HeaderText="I.A." SortExpression="IntAccess" />
                <asp:CheckBoxField DataField="nsf" HeaderText="N.S.F." SortExpression="nsf" />
                <asp:CheckBoxField DataField="loanComp" HeaderText="L.C." SortExpression="loanComp" />
                <asp:BoundField DataField="remarks" HeaderText="Remarks" SortExpression="remarks" />
            </Columns>

        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IT-app-v4-ConnectionString %>" SelectCommand="SELECT * FROM [Applicant]" FilterExpression="[AppTypeName] LIKE '%{0}%'">
        <FilterParameters>
            <asp:ControlParameter Name="AppTypeName" ControlID="FormView1$StatusLbl" PropertyName="text"/>
            <asp:ControlParameter Name="name" ControlID="FormView1$nameLbl" PropertyName="text"/>
            <asp:ControlParameter Name="designation" ControlID="FormView1$designationLbl" PropertyName="text"/>
            <asp:ControlParameter Name="OfficeName" ControlID="FormView1$OfficeLbl" PropertyName="text"/>
            <asp:ControlParameter Name="floorNo" ControlID="FormView1$FloorLbl" PropertyName="text"/>
            <asp:ControlParameter Name="DeptName" ControlID="FormView1$DeptLbl" PropertyName="text"/>
            <asp:ControlParameter Name="projectType" ControlID="FormView1$ProjectLbl" PropertyName="text"/>
            <asp:ControlParameter Name="emailDiversionType" ControlID="FormView1$emailDiversionLbl" PropertyName="text"/>
            <asp:ControlParameter Name="IntAccess" ControlID="FormView1$IntAccessCheckBox" PropertyName="Checked"/>
            <asp:ControlParameter Name="nsf" ControlID="FormView1$nsfCheckBox" PropertyName="Checked"/>
            <asp:ControlParameter Name="loanComp" ControlID="FormView1$loanCompCheckBox" PropertyName="Checked"/>
        </FilterParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

report.aspx.cs

protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void GenerateBtn_Click(object sender, EventArgs e)
        {
            string url = "GenReport.aspx?status=" + status.SelectedValue + "&name=" + name.Text + "&designation=" + designation.Text + "&office=" + office.SelectedValue + "&floor=" + floor.SelectedValue + "&dept=" + dept.SelectedValue + "&project=" + project.SelectedValue + "&emailDiv=" + emailDiv.SelectedValue + "&IA=" + IA.Checked + "&NSF=" + NSF.Checked + "&LC=" + LC.Checked;
            Response.Redirect(url);
        }

report.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="report.aspx.cs" Inherits="IT_application_form_v4.admin.report" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <br />
    <div class="panel panel-success">
        <div class="panel-heading"><h3 class="panel-title">FILTER BY</h3></div>
        <div class="panel-body">
        <br />
        <table style="width:100%;">
            <tr>
                <td class="modal-sm" style="width: 350px"><strong>STATUS:</strong></td>
                <td rowspan="7" style="width: 33px">&nbsp;</td>
                <td style="width: 177px"><strong>OFFICE:</strong></td>
                <td>
                    <asp:DropDownList ID="office" runat="server" CssClass="form-control" Width="300px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>Menara Gamuda</asp:ListItem>
                        <asp:ListItem>Menara MK</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="modal-sm" style="width: 350px">
                    <asp:DropDownList ID="status" runat="server" CssClass="form-control" Width="300px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>New</asp:ListItem>
                        <asp:ListItem>Transfer</asp:ListItem>
                        <asp:ListItem>Existing</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td style="width: 177px"><strong>FLOOR:</strong></td>
                <td>
                    <asp:DropDownList ID="floor" runat="server" CssClass="form-control" Width="300px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>8</asp:ListItem>
                        <asp:ListItem>9</asp:ListItem>
                        <asp:ListItem>10</asp:ListItem>
                        <asp:ListItem>11</asp:ListItem>
                        <asp:ListItem>12</asp:ListItem>
                        <asp:ListItem>13</asp:ListItem>
                        <asp:ListItem>14</asp:ListItem>
                        <asp:ListItem>15</asp:ListItem>
                        <asp:ListItem>16</asp:ListItem>
                        <asp:ListItem>17</asp:ListItem>
                        <asp:ListItem>18</asp:ListItem>
                        <asp:ListItem>19</asp:ListItem>
                        <asp:ListItem>20</asp:ListItem>
                        <asp:ListItem>21</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="modal-sm" style="width: 350px"><strong>NAME (Starts with):</strong></td>
            </tr>
            <tr>
                <td class="modal-sm" style="height: 11px; width: 350px">
                    <asp:TextBox ID="name" runat="server" CssClass="form-control" Width="275px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="modal-sm" style="height: 11px; width: 350px">
                    &nbsp;</td>
                <td style="height: 11px; width: 177px"><strong>DEPARTMENT:</strong></td>
                <td style="height: 11px">
                    <asp:DropDownList ID="dept" runat="server" CssClass="form-control" Width="300px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>Contracts & Commercial</asp:ListItem>
                        <asp:ListItem>Design & Technical</asp:ListItem>
                        <asp:ListItem>Finance</asp:ListItem>
                        <asp:ListItem>Human Resources & Administration</asp:ListItem>
                        <asp:ListItem>Information Technology</asp:ListItem>
                        <asp:ListItem>Operations</asp:ListItem>
                        <asp:ListItem>Project Management</asp:ListItem>
                        <asp:ListItem>Safety & Health</asp:ListItem>
                        <asp:ListItem>Systems</asp:ListItem>
                        <asp:ListItem>Tunnel</asp:ListItem>
                        <asp:ListItem>Underground Station</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="modal-sm" style="width: 350px"><strong>DESIGNATION (Starts with):</strong></td>
            </tr>
            <tr>
                <td class="modal-sm" style="width: 350px">
                    <asp:TextBox ID="designation" runat="server" CssClass="form-control" Width="275px"></asp:TextBox>
                </td>
                <td style="width: 177px">&nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>

    </div>
    <div class="panel-body">

        <table style="width:100%;">
            <tr>
                <td style="width: 230px"><b>PROJECT:</b></td>
                <td>
                    <asp:DropDownList ID="project" runat="server" CssClass="form-control" Width="300px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>EDTP</asp:ListItem>
                        <asp:ListItem>KVMRT (UG)</asp:ListItem>
                        <asp:ListItem>KVMRT (PDP)</asp:ListItem>
                        <asp:ListItem>Others</asp:ListItem>
                    </asp:DropDownList>
                &nbsp;</td>
            </tr>
            <tr>
                <td style="width: 230px"><b>E-MAIL DIVERSION:</b></td>
                <td>
                    <asp:DropDownList ID="emailDiv" runat="server" CssClass="form-control" Width="300px" DataTextField="desc" DataValueField="emailDiversionType">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem Value="NONE">None</asp:ListItem>
                        <asp:ListItem Value="M2G">MGJV to Gamuda</asp:ListItem>
                        <asp:ListItem Value="G2M">Gamuda to MGJV</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="2"></td>
            </tr>
        </table>

    </div>
    <div class="panel-body">
        <table style="width: 100%;">
            <tr>
                <td style="width: 182px"><strong>Internet Access: </strong><asp:CheckBox ID="IA" runat="server" /></td>
                <td style="width: 217px"><strong>Network Shared Folder: </strong><asp:CheckBox ID="NSF" runat="server" /></td>
                <td><strong>Loan Computer: </strong><asp:CheckBox ID="LC" runat="server" /></td>
            </tr>
        </table>
    </div>
        <div class="panel-body"><asp:Button ID="GenerateBtn" runat="server" Text="Generate" CssClass="btn btn-primary" OnClick="GenerateBtn_Click"/></div>
    </div>
</asp:Content>

MDF files (required to connect): https://drive.google.com/file/d/0B07_pOHhTox3YnBRUTNfbXJUYnc/view?usp=sharing

From a quick first view I can not see how your dataset is being filtered in your report.aspx.cs file. There is no query to the database that will return the filtered dataset to bind it to your grid view. Thats way it displays the whole data set. But I will look at it closer some other time.

use session to pass filter dataset from gridform to report page.

I've changed the majority of the coding, but it still not effective.

GenReport.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GenReport.aspx.cs" Inherits="IT_application_form_v4.admin.GenReport" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            text-decoration: underline;
        }
        .auto-style4 {
            width: 20px;
        }
        .auto-style5 {
            width: 87px;
        }
        .auto-style6 {
            width: 233px;
        }
        .auto-style7 {
            width: 255px;
        }
        .auto-style8 {
            width: 171px;
        }
        .auto-style9 {
            width: 230px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="PrintButton" runat="server" Text="Print" OnClientClick="javascript:window.print();"/>

    <div align="center">
    <asp:Image ID="mmcGamudaLogo" runat="server" Height="94px" ImageAlign="Middle" ImageUrl="img/mmc-gamuda logo large.png" style="text-align: center" /><br />
    <strong>APPLICANT LIST</strong>
    </div>

    <div class="panel panel-default">
        <div class="panel-body">
            <asp:FormView ID="FormView1" runat="server">
            <ItemTemplate>
                <strong>Printed On: </strong>
                <asp:Label ID="printDateTime" runat="server" Text='<%# Bind("Date") %>'></asp:Label>
                <br />
                <strong>Printed By: </strong>

                <hr />

                <span class="auto-style1"><strong>FILTERS:</strong></span><br />
                <table style="width: 100%;">
                    <tr>
                        <td class="auto-style8"><b>Status:</b></td>
                        <td class="auto-style9">
                            <asp:Label ID="StatusLbl" runat="server" Text='<%# Eval("AppTypeName") %>'></asp:Label>
                        </td>
                        <td class="auto-style4" rowspan="3">&nbsp;</td>
                        <td class="auto-style5"><b>Office:</b></td>
                        <td class="auto-style6">
                            <asp:Label ID="OfficeLbl" runat="server" Text='<%# Eval("OfficeName") %>'></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style8"><b>Name (starts with):</b></td>
                        <td class="auto-style9">
                            <asp:Label ID="nameLbl" runat="server" Text='<%# Eval("name") %>'></asp:Label>
                        </td>
                        <td class="auto-style5"><b>Floor:</b></td>
                        <td class="auto-style6">
                            <asp:Label ID="FloorLbl" runat="server" Text='<%# Eval("floorNo") %>'></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style8"><b>Designation (starts with):</b></td>
                        <td class="auto-style9">
                            <asp:Label ID="designationLbl" runat="server" Text='<%# Eval("designation") %>'></asp:Label>
                        </td>
                        <td class="auto-style5"><b>Department:</b></td>
                        <td class="auto-style6">
                            <asp:Label ID="DeptLbl" runat="server" Text='<%# Eval("DeptName") %>'></asp:Label>
                        </td>
                    </tr>
                </table>
                <hr />
                <b>Project: </b>
                <asp:Label ID="ProjectLbl" runat="server" Text='<%# Eval("projectType") %>'></asp:Label>

                <br />
                <strong>E-mail Diversion:</strong>
                <asp:Label ID="emailDiversionLbl" runat="server" Text='<%# Eval("emailDiversionType") %>'></asp:Label>
                <hr />
                <table style="width: 100%;">
                    <tr>
                        <td><b>Internet Access: </b>
                            <asp:Label ID="IA_lbl" runat="server" Text='<%# Bind("ia_num") %>'></asp:Label></td>
                        <td><b>Network Shared Folder: </b>
                            <asp:Label ID="NSF_lbl" runat="server" Text='<%# Bind("nsf_num") %>'></asp:Label></td>
                        <td><b>Loan Computer: </b>
                            <asp:Label ID="LC_lbl" runat="server" Text='<%# Bind("lc_num") %>'></asp:Label></td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:FormView>
        </div>
    </div>
    <br />
    <div>
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="AppTypeName" HeaderText="Status" SortExpression="AppTypeName" />
                <asp:BoundField DataField="name" HeaderText="Name" SortExpression="name" />
                <asp:BoundField DataField="designation" HeaderText="Designation" SortExpression="designation" />
                <asp:BoundField DataField="OfficeName" HeaderText="Office" SortExpression="OfficeName" />
                <asp:BoundField DataField="floorNo" HeaderText="Floor" SortExpression="floorNo" />
                <asp:BoundField DataField="DeptName" HeaderText="Dept" SortExpression="DeptName" />
                <asp:BoundField DataField="projectType" HeaderText="Project" SortExpression="projectType" />
                <asp:CheckBoxField DataField="EmailID" HeaderText="E-mail ID" SortExpression="EmailID" />
                <asp:CheckBoxField DataField="EmailGroup" HeaderText="E-mail Group" SortExpression="EmailGroup" />
                <asp:BoundField DataField="EmailGroupName" HeaderText="E-mail Group Name" SortExpression="EmailGroupName" />
                <asp:BoundField DataField="emailDiversionType" HeaderText="E-mail Div" SortExpression="emailDiversionType" />
                <asp:BoundField DataField="emailDiversionAdd" HeaderText="E-mail Div ID" SortExpression="emailDiversionAdd" />
                <asp:CheckBoxField DataField="IntAccess" HeaderText="I.A." SortExpression="IntAccess" />
                <asp:CheckBoxField DataField="nsf" HeaderText="N.S.F." SortExpression="nsf" />
                <asp:CheckBoxField DataField="loanComp" HeaderText="L.C." SortExpression="loanComp" />
                <asp:BoundField DataField="remarks" HeaderText="Remarks" SortExpression="remarks" />
            </Columns>

        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IT-app-v4-ConnectionString %>" SelectCommand="SELECT * FROM [Applicant]" >
        <FilterParameters>
            <asp:ControlParameter Name="AppTypeName" ControlID="FormView1$StatusLbl" PropertyName="text"/>
            <asp:ControlParameter Name="name" ControlID="FormView1$nameLbl" PropertyName="text"/>
            <asp:ControlParameter Name="designation" ControlID="FormView1$designationLbl" PropertyName="text"/>
            <asp:ControlParameter Name="OfficeName" ControlID="FormView1$OfficeLbl" PropertyName="text"/>
            <asp:ControlParameter Name="floorNo" ControlID="FormView1$FloorLbl" PropertyName="text"/>
            <asp:ControlParameter Name="DeptName" ControlID="FormView1$DeptLbl" PropertyName="text"/>
            <asp:ControlParameter Name="projectType" ControlID="FormView1$ProjectLbl" PropertyName="text"/>
            <asp:ControlParameter Name="emailDiversionType" ControlID="FormView1$emailDiversionLbl" PropertyName="text"/>
            <asp:ControlParameter Name="IntAccess" ControlID="FormView1$IA_lbl" PropertyName="text"/>
            <asp:ControlParameter Name="nsf" ControlID="FormView1$NSF_lbl" PropertyName="text"/>
            <asp:ControlParameter Name="loanComp" ControlID="FormView1$LC_lbl" PropertyName="text"/>
        </FilterParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

GenReport.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using System.Text;
using System.Configuration;

namespace IT_application_form_v4.admin
{

    public partial class GenReport : System.Web.UI.Page
    {
        DataTable dt;

        string AppTypeName = "";
        string name = "";
        string designation = "";
        string OfficeName = "";
        string floorNo = "";
        string DeptName = "";
        string projectType = "";
        string emailDiversionType = "";

        string ia_num = "";
        string nsf_num = "";
        string lc_num = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["IT-app-v4-ConnectionString"].ConnectionString);

            if (!IsPostBack)
            {
                dt = new DataTable();
                dt.Columns.Add(new DataColumn() { ColumnName = "AppTypeName", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "name", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "designation", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "OfficeName", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "floorNo", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "DeptName", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "projectType", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "emailDiversionType", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "ia_num", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "nsf_num", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "lc_num", DataType = typeof(string) });
                dt.Columns.Add(new DataColumn() { ColumnName = "Date", DataType = typeof(DateTime) });

                AppTypeName = Request.QueryString["status"];
                name = Request.QueryString["name"];
                designation = Request.QueryString["designation"];
                OfficeName = Request.QueryString["office"];
                floorNo = Request.QueryString["floor"];
                DeptName = Request.QueryString["dept"];
                projectType = Request.QueryString["project"];
                emailDiversionType = Request.QueryString["emailDiv"];

                ia_num = Request.QueryString["IAc"];
                nsf_num = Request.QueryString["NSFo"];
                lc_num = Request.QueryString["LCo"];

                dt.Rows.Add(AppTypeName, name, designation, OfficeName, floorNo, DeptName, projectType, emailDiversionType, ia_num, nsf_num, lc_num, DateTime.Now);
                // I have made the Date as DateTime.Now

                string strFilter = "";

                if (!string.IsNullOrEmpty(AppTypeName) || !string.IsNullOrEmpty(name) || !string.IsNullOrEmpty(designation) || !string.IsNullOrEmpty(OfficeName) || !string.IsNullOrEmpty(floorNo) || !string.IsNullOrEmpty(DeptName) || !string.IsNullOrEmpty(projectType) || !string.IsNullOrEmpty(emailDiversionType) || !string.IsNullOrEmpty(ia_num) || !string.IsNullOrEmpty(nsf_num) || !string.IsNullOrEmpty(lc_num))
                {
                    strFilter = "WHERE ";
                    if (!string.IsNullOrEmpty(AppTypeName))
                    {
                        strFilter += "[AppTypeName] LIKE '" + AppTypeName + "' AND ";
                    }
                    if (!string.IsNullOrEmpty(name))
                    {
                        strFilter += "[name] LIKE '" + name + "%' AND ";
                    }
                    if (!string.IsNullOrEmpty(designation))
                    {
                        strFilter += "[designation] LIKE '" + designation + "%' AND ";
                    }
                    if (!string.IsNullOrEmpty(OfficeName))
                    {
                        strFilter += "[OfficeName] LIKE '" + OfficeName + "' AND ";
                    }
                    if (!string.IsNullOrEmpty(floorNo))
                    {
                        strFilter += "[floorNo] LIKE '" + floorNo + "' AND ";
                    }
                    if (!string.IsNullOrEmpty(DeptName))
                    {
                        strFilter += "[DeptName] LIKE '" + DeptName + "' AND ";
                    }
                    if (!string.IsNullOrEmpty(projectType))
                    {
                        strFilter += "[projectType] LIKE '" + projectType + "' AND ";
                    }
                    if (!string.IsNullOrEmpty(emailDiversionType))
                    {
                        strFilter += "[emailDiversionType] LIKE '" + emailDiversionType + "' AND ";
                    }
                    if (!string.IsNullOrEmpty(ia_num))
                    {
                        strFilter += "[IntAccess] LIKE '" + ia_num + "%' AND ";
                    }
                    if (!string.IsNullOrEmpty(nsf_num))
                    {
                        strFilter += "[nsf] LIKE '" + nsf_num + "%' AND ";
                    }
                    if (!string.IsNullOrEmpty(lc_num))
                    {
                        strFilter += "[loanComp] LIKE '" + lc_num + "%'";
                    }
                }

                SqlDataSource1.FilterExpression = strFilter;

                FormView1.DataSource = dt;
                FormView1.DataBind();
            }
        }

    }
}

It seems to me that your problem is most propably in the concatenation of your filter condition. And I am explain myself. I see that your filter is a binary or condition. That means that any of your filter parameters could, actually, be inside the filter string. So when you are starting to concatanate, all the filter strings are ending, correctlly, with an "AND" clause, except from the last one. Now here i think is your problem. If your last filter string (strFilter += "[loanComp] LIKE '" + lc_num + "%'";) is not chosen inside your filter then all your filter contition string ends with an "%' AND " and that is causing your problem.
Try to put the "%' AND " string also in your final filter substring I mentioned above and then just before you apply your filter condition cut off the final 7 characters from the string.
Hope I helped.

I've added a line of the code inside the 'if' statement.
strFilter = strFilter.Substring(strFilter.Length - 7);

When I want to filter everything, it gives me an error: Missing operand before 'Mod' operator. When I want to filter some, it still shows all the results instead of filtered.

that is probably becouse the substraction ends in the % symbol (I mighht have missed a charackter in the count), so make the "-7" -> "-8" and see what it gives.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.