|
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)
{
try
{
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);
ReportViewer1.LocalReport.SetParameters(param);
ReportDataSource rds = new ReportDataSource("DataSet1_Customers_DataTable1", customerList);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
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)
{
try
{
BindReportViewer();
}
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.