Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Dynamic Binding Of RDLC To ReportViewer

, 17 Dec 2008 CPOL
This article demonstrates how to bind reportviewer control dynamically with Datasource at runtime.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Reporting.WebForms;
using System.Collections.Generic;

public partial class _Default : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e)
            ReportViewer1.Visible = false;
        catch (Exception ex)
            throw ex;
    private void BindReportViewer()
        ReportViewer1.Visible = true;
        //Invoke Stored procedure With Input parameter to it.
        //DataSet dsReport = objSP.GetTable(storedProcedure,txtParameter.Text));
        //Hardcoded Values.
        IList<Customer> customerList = new List<Customer>();
        customerList.Add(new Customer(1,"Santosh Poojari"));
        customerList.Add(new Customer(2, "Santosh Poojari1"));
        customerList.Add(new Customer(3, "Santosh Poojari2"));
        ReportParameter[] param = new ReportParameter[1];
        param[0] = new ReportParameter("Report_Parameter_0",txtParameter.Text);

        ReportDataSource rds = new ReportDataSource("DataSet1_Customers_DataTable1", customerList);
    private class Customer
        private int m_CustomerID;
        private string m_CustomerName;
        public Customer(int customerId, string customerName)
            m_CustomerID = customerId;
            m_CustomerName = customerName;
        public int CustomerID
            get { return m_CustomerID; }
            set { m_CustomerID = value; }
        public string CustomerName
            get { return m_CustomerName; }
            set { m_CustomerName = value; }
    protected void Button1_Click(object sender, EventArgs e)
        catch(Exception ex)
            throw ex;


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

santosh poojari
Technical Lead
India India
Whatsup-->Exploring--> MVC/HTML5/Javascript & Virtualization.......!

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150327.1 | Last Updated 18 Dec 2008
Article Copyright 2008 by santosh poojari
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid