ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Filter RDLC Report ReportViewer control using DropDownList selection in ASP.Net<p>Reference:</p> <h1 class="header"><a title="RDLC (Local SSRS) Report ASP.Net Example using DataSet or DataTable in C# VB.Net and Visual Studio 2010'a" href="http://aspsnippets.com/Articles/RDLC-Local-SSRS-Report-ASPNet-Example-using-DataSet-or-DataTable-in-C-VBNet-and-Visual-Studio-2010.aspx">RDLC (Local SSRS) Report ASP.Net Example using DataSet or DataTable in C# VB.Net and Visual Studio 2010</a></h1> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;asp:ScriptManager ID=&#34;ScriptManager1&#34; runat=&#34;server&#34;&gt; &lt;/asp:ScriptManager&gt; Please Select Country :&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;asp:DropDownList ID=&#34;ddlCountries&#34; runat=&#34;server&#34; OnSelectedIndexChanged=&#34;Countries_SelectedIndexChanged&#34; AutoPostBack=&#34;true&#34;&gt; &lt;/asp:DropDownList&gt; &lt;rsweb:ReportViewer ID=&#34;ReportViewer1&#34; runat=&#34;server&#34; Width=&#34;600&#34;&gt; &lt;/rsweb:ReportViewer&gt;</pre> <p><span style="text-decoration: underline;">Code</span></p> <pre class="brush: csharp">string conString = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.GetCountries(); this.BindRDLCReport(); } } private void BindRDLCReport() { ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath(&#34;~/Report.rdlc&#34;); Customers dsCustomers = GetData(&#34;SELECT TOP 20 * FROM Customers WHERE Country = @Country OR @Country = &#39;&#39;&#34;); ReportDataSource datasource = new ReportDataSource(&#34;Customers&#34;, dsCustomers.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } protected void Countries_SelectedIndexChanged(object sender, EventArgs e) { this.BindRDLCReport(); } private Customers GetData(string query) { SqlCommand cmd = new SqlCommand(query); using (SqlConnection con = new SqlConnection(conString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; cmd.Parameters.AddWithValue(&#34;@Country&#34;, this.ddlCountries.SelectedItem.Value); sda.SelectCommand = cmd; using (Customers dsCustomers = new Customers()) { sda.Fill(dsCustomers, &#34;DataTable1&#34;); return dsCustomers; } } } } private void GetCountries() { SqlCommand cmd = new SqlCommand(&#34;SELECT DISTINCT Country FROM Customers&#34;); using (SqlConnection con = new SqlConnection(conString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; DataTable dtCountries = new DataTable(); sda.Fill(dtCountries); ddlCountries.DataSource = dtCountries; ddlCountries.DataTextField = &#34;Country&#34;; ddlCountries.DataValueField = &#34;Country&#34;; ddlCountries.DataBind(); ddlCountries.Items.Insert(0, new ListItem(&#34;Select&#34;, &#34;&#34;)); } } }</pre> <p><span style="text-decoration: underline;">Screenshots</span></p> <p>1) On Page Load</p> <p><img src="https://i.imgur.com/zEp5liH.png" alt="" width="472" height="334" /></p> <p>2) After Selecting Country</p> <p><img src="https://i.imgur.com/U1dzI7U.png" alt="" width="472" height="334" /></p>https://www.aspforums.net:443/Threads/634385/Filter-RDLC-Report-ReportViewer-control-using-DropDownList-selection-in-ASPNet/https://www.aspforums.net:443/Threads/634385/Filter-RDLC-Report-ReportViewer-control-using-DropDownList-selection-in-ASPNet/Mon, 02 Feb 2015 03:31:16 GMT