视图有一个运行SSR的中央报表服务器,我们的所有报表都已构建并显示在服务器上。
现在如何使用ASP.NET中的ReportViewer Control显示其中一个报表?
我的控制:
<rsweb:ReportViewer ID="ctReportViewer" runat="server" />
我的CodeBehind:
var reportServer = ctReportViewer.ServerReport;
reportServer.ReportServerUrl = new Uri(@"http://<MYSERVERNAMEHERE>/reportsdev");
reportServer.ReportPath = @"/OneFm/ArrearCollectionPerRegion";
reportServer.ReportServerCredentials = new ReportViewerCredentials("<USERNAME>", "<PASSWORD>", "<DOMAIN>");
ctReportViewer.DataBind();
public partial class ReportViewerCredentials : IReportServerCredentials
{
private string _userName;
private string _password;
private string _domain;
public ReportViewerCredentials(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null;
}
}
public ICredentials NetworkCredentials
{
get
{
return new NetworkCredential(_userName, _password, _domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie,
out string userName, out string password,
out string authority)
{
authCookie = null;
userName = _userName;
password = _password;
authority = _domain;
// Not using form credentials
return false;
}
}
链接报告:
http://<MYSERVERNAMEHERE>/ReportsDev/Pages/Report.aspx?ItemPath=/OneFm/ArrearCollectionPerRegion
我到处找。
我运行的是SSRS2005,如果有必要的话,我使用的是VS2008。
一个例子是值得赞赏的。