Click here to Skip to main content
16,017,488 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I have generated SSRS reports, now i want to print my reports from asp.net button click, by passing input parameters from some controls in asp.net page.
How to achieve this , any sample code really helpful to start.
Thanks in advance.
Posted

Although it's Sql 2005 I think this is quite good walkthrough: http://msdn.microsoft.com/en-us/library/aa964126(SQL.90).aspx[^]
 
Share this answer
 
protected void btnReport_Click(object sender, EventArgs e)

{

ReportParameter[] parm = new ReportParameter[1];

parm[0] =new ReportParameter("deptno",txtDeptno.Text);

ReportViewer1.ShowCredentialPrompts = false;

ReportViewer1.ServerReport.ReportServerCredentials = new ReportCredentials("Reportfolder Name", "Password of the folder", "");

ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;

ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://ReportServer/ReportServer");

ReportViewer1.ServerReport.ReportPath = "/ReportFolder/ReportName";

ReportViewer1.ServerReport.SetParameters(parm);

ReportViewer1.ServerReport.Refresh();
}

In the above code ReportParameter are the report parameters used to display the report.

ReportFolderName is the folder where we have deployed the report on the Report server.

Password of the Folder this is the password for that folder on the report server.

Next step is about the class, which implements the Microsoft.Reporting.WebForms.IReportServerCredentials interface for accessing the reports.

public class ReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials

{

string _userName, _password, _domain;

public ReportCredentials(string userName, string password, string domain)

{

_userName = userName;

_password = password;

_domain = domain;

}

public System.Security.Principal.WindowsIdentity ImpersonationUser

{

get

{

return null;

}

}



public System.Net.ICredentials NetworkCredentials

{

get

{

return new System.Net.NetworkCredential(_userName, _password, _domain);

}

}



public bool GetFormsCredentials(out System.Net.Cookie authCoki, out string userName, out string password, out string authority)

{

userName = _userName;

password = _password;

authority = _domain;

authCoki = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", "Domain");

return true;

}

}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900