aspx
that has a print button, when I click print I want to call the rdlc that I have created for printing. How do I?
aspx
that has a print button, when I click print I want to call the rdlc that I have created for printing. How do I?
The Print button should call another aspx. In this aspx, you can do as follows:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
var dsClientes = GetData("select top 20 * from clientes");
ReportDataSource datasource = new ReportDataSource("Clientes", dsClientes.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
}
private Customers GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlCommand cmd = new SqlCommand(query);
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (Customers dsClientes = new Customers())
{
sda.Fill(dsClientes, "DataTable1");
return dsClientes;
}
}
}
}