Filter RDLC (Local SSRS) Report Data using CheckBoxes in ASP.Net

Last Reply on Jan 09, 2014 07:10 AM By Azim

Posted on Jan 08, 2014 06:47 AM

how to apply filter using checkbox and by selecting multiple checkbox

You are viewing reply posted by: Azim on Jan 09, 2014 07:10 AM.
Posted on Jan 09, 2014 07:10 AM

Ref:RDLC (Local SSRS) Report ASP.Net Example using DataSet or DataTable in C# VB.Net and Visual Studio 2010

Download the sample from above link and modify the HTML form:

<form id="form1" runat="server">
    <asp:CheckBoxList ID="chkCountryDemo" AutoPostBack="true" OnSelectedIndexChanged="ProductsType_Changed"
        runat="server">
        <asp:ListItem Text="Mexico" Value="0" />
        <asp:ListItem Text="Germany" Value="1" />
        <asp:ListItem Text="Sweden" Value="3" />
        <asp:ListItem Text="France" Value="4" />
    </asp:CheckBoxList>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="600">
    </rsweb:ReportViewer>
    </form>

Add this Event in code:

protected void ProductsType_Changed(object sender, EventArgs e)
    {
        string query = "SELECT * FROM customers";

        query += " WHERE Country IN (";
        foreach (ListItem item in chkCountryDemo.Items)
        {
            if (item.Selected)
            {
                query += "'" + item.Text + "'" + ",";
            }
        }
        query = query.Substring(0, query.Length - 1);
        query += ")";

        Customers dsCustomers = GetData(query);
        ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(datasource);
    }

Thank You