I'm having a problem with the ASP.NET version of the ReportViewer control for SSRS.
In my ASP.NET web forms file I have:
<rsweb:ReportViewer ID="webViewer" runat="server" Width="100%" Height="100%"
ProcessingMode="Remote">
<ServerReport ReportPath="/AnalyticReports/SiteOverview"
ReportServerUrl="http://someserver/ssrs" />
</rsweb:ReportViewer>
This works fine and dandy as expected.
However, say I want to change the server and report path programmatically. How would I do that?
I tried this:
webViewer.ServerReport.ReportServerUrl = new Uri("http://someserver/ssrs");
webViewer.ServerReport.ReportPath = "/AnalyticReports/SiteOverview";
webViewer.ServerReport.Refresh();
However that doesn't seem to do anything. I even tried adding a webViewer.Reset() but to no avail.
Anyone point me in the right direction?
Actually, it seems that the problem lies with the Page_Load
event. After coming across http://msdn.microsoft.com/en-us/library/aa337091.aspx I tried Page_Init
and things seem to work as expected.
i did this using a property which will get and set the values
public string ReportPathString
{ get { return ReportViewer1.ServerReport.ReportPath; }
set { ReportViewer1.ServerReport.ReportPath = value; }
}
public string ReportServerUrlString
{ get { return ReportViewer1.ServerReport.ReportServerUrl.ToString(); }
set { ReportViewer1.ServerReport.ReportServerUrl = new Uri(value); }
}
also while at page_load, i use the following code for setting the credentials
IReportServerCredentials irsc = new ReportServerCredentials("Username", "Password", "Domain");
the class that is use like below
public class ReportServerCredentials : IReportServerCredentials
{
private string _UserName;
private string _PassWord;
private string _DomainName;
public ReportServerCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
// use default identity
get { return null; }
}
public ICredentials NetworkCredentials
{
// use default identity
get { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
}
public bool GetFormsCredentials(out Cookie authCookie, out string user,
out string password, out string authority)
{
authCookie = null;
user = password = authority = null;
return false;
}
}
EDIT: just saw the topic is a year old ...
你试过这个吗,劳埃德?
webViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
I use LocalReport which seemed to work better:
var reportDataSource = new ReportDataSource("DataSet1", resultSet);
ReportViewer1.LocalReport.ReportPath = Server.MapPath("/Reports/" + reportName + ".rdl");
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
ReportViewer1.LocalReport.Refresh();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.