gpt4 book ai didi

c# - 以编程方式控制 SQL Server Reporting Services 报表查看器

转载 作者:行者123 更新时间:2023-11-30 15:37:55 27 4
gpt4 key购买 nike

我在使用 SSRS 的 ReportViewer 控件的 ASP.NET 版本时遇到问题。

在我的 ASP.NET 网络表单文件中我有:

    <rsweb:ReportViewer ID="webViewer" runat="server" Width="100%" Height="100%" 
ProcessingMode="Remote">
<ServerReport ReportPath="/AnalyticReports/SiteOverview"
ReportServerUrl="http://someserver/ssrs" />
</rsweb:ReportViewer>

这如预期的那样工作得很好。

但是,假设我想以编程方式更改服务器和报告路径。我该怎么做?

我试过这个:

webViewer.ServerReport.ReportServerUrl = new Uri("http://someserver/ssrs");
webViewer.ServerReport.ReportPath = "/AnalyticReports/SiteOverview";
webViewer.ServerReport.Refresh();

然而,这似乎并没有做任何事情。我什至尝试添加 webViewer.Reset() 但无济于事。

有人指出我正确的方向吗?

最佳答案

我使用一个属性来获取和设置值

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); }
}

同样在 page_load 时,我使用以下代码设置凭据

IReportServerCredentials irsc = new ReportServerCredentials("Username", "Password", "Domain");

类如下所示

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;
}


}

编辑:刚看到这个话题是一岁...

关于c# - 以编程方式控制 SQL Server Reporting Services 报表查看器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12040804/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com