In this article I will explain with an example, how to filter RDLC Report in ASP.Net using C# and VB.Net.
RDLC Report data will be filtered on selection of DropDownList in ASP.Net.
Here I am making use of Microsoft’s Northwind Database. You can download it from here.
HTML Markup
The HTML Markup consists of a RDLC ReportViewer control, a DropDownList to filter RDLC Report.
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:DropDownList ID="ddlCountries" runat="server" OnSelectedIndexChanged="CountryChanged"
    <asp:ListItem Text="All" Value="" />
    <asp:ListItem Text="Spain" Value="Spain" />
    <asp:ListItem Text="Germany" Value="Germany" />
    <asp:ListItem Text="France" Value="France" />
    <asp:ListItem Text="Canada" Value="Canada" />
<hr />
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="500" SizeToReportContent="true">
You will need to import the following namespaces.
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebForms
Designing and populating the RDLC Report from Database
Inside the Page Load event, the RDLC Report is populated from database using the BindReport function.
Note: For more details about designing and populating RDLC Report, please refer the following article.
         RDLC (Local SSRS) Report ASP.Net Example
Inside the BindReport function, the selected value of the DropDownList i.e. the selected Country is passed to the GetData function where the value is passed as parameter and the records are filtered.
protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
private void BindReport()
    ReportViewer1.ProcessingMode = ProcessingMode.Local;
    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
    Customers dsCustomers = GetData(ddlCountries.SelectedItem.Value);
    ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
private Customers GetData(string country)
    string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    using (SqlCommand cmd = new SqlCommand("SELECT TOP 10 * FROM Customers WHERE Country = @Country OR @Country = ''"))
        using (SqlConnection con = new SqlConnection(conString))
            using (SqlDataAdapter sda = new SqlDataAdapter())
                cmd.Connection = con;
                sda.SelectCommand = cmd;
                cmd.Parameters.AddWithValue("@Country", country);
                using (Customers dsCustomers = new Customers())
                    sda.Fill(dsCustomers, "DataTable1");
                    return dsCustomers;
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
    End If
End Sub
Private Sub BindReport()
    ReportViewer1.ProcessingMode = ProcessingMode.Local
    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc")
    Dim dsCustomers As Customers = GetData(ddlCountries.SelectedItem.Value)
    Dim datasource As ReportDataSource = New ReportDataSource("Customers", dsCustomers.Tables(0))
End Sub
Private Function GetData(ByVal country As String) As Customers
    Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
    Using cmd As SqlCommand = New SqlCommand("SELECT TOP 10 * FROM Customers WHERE Country = @Country OR @Country = ''")
        Using con As SqlConnection = New SqlConnection(conString)
            Using sda As SqlDataAdapter = New SqlDataAdapter()
                cmd.Connection = con
                sda.SelectCommand = cmd
                cmd.Parameters.AddWithValue("@Country", country)
                Using dsCustomers As Customers = New Customers()
                    sda.Fill(dsCustomers, "DataTable1")
                    Return dsCustomers
                End Using
            End Using
        End Using
    End Using
End Function
Filter RDLC Report using DropDownList in ASP.Net using C# and VB.Net
When a Country is selected in the DropDownList, the BindReport function is again called.
protected void CountryChanged(object sender, EventArgs e)
Protected Sub CountryChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Filter RDLC Report in ASP.Net using C# and VB.Net