惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements

博客园 - 蒜头

Mailbox unavailable. The server response was: 5.7.1 Unable to relay for (email address). 再谈Images到xps,pdf的转换 SQL Server 2005中xml类型和函数的简单应用 部分Office 2007文件格式转换为xps和pdf代码整理 Image.FromFile gives "Out of Memory" Exception for icon - 蒜头 简单介绍PDF,XPS,Images,Office 2007之间的转换方法 - 蒜头 - 博客园 SQL 2005 全文检索(续) 简单实现C#生成Excel 2007文件并下载 配置SQL Server Session方法 采用负载均衡,部署了两个ASP.NET 2.0的站点服务器碰到的问题 初试VSTS 2008(TFS安装) Windows Server 2003分区修改方法[转载] 制作VSTO 2005 SE开发的Office 2007 AddIn的安装包 一个简单的document library event handler VS 2005 SP1 安装错误 [续] 一个简单的Checkbox Custom Field Type ASP.NET 2.0 SQL Cache 配置方法 解读Document Library关于权限的对象模型 SharePoint应用AJAX.NET和AJAX Control Toolkit
简单应用ReportViewer控件
蒜头 · 2008-01-28 · via 博客园 - 蒜头

首先,将开发好的report部署到Reporting Service上。

1. 写一个类实现接口Microsoft.Reporting.WebForms.IReportServerCredentials,用于Reporting Service的验证,有1个方法,2个属性,根据运行环境来实现这个接口,我这里使用环境的Web程序,Reporting Service需要Window身份验证:

        public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string userName, out string password, out string authority)
        
{
            userName 
= String.Empty;
            password 
= String.Empty;
            authority 
= String.Empty;
            authCookie 
= null;

            
return false;
        }

        
public System.Security.Principal.WindowsIdentity ImpersonationUser
        
{
            
get return null; }
        }


        
public System.Net.ICredentials NetworkCredentials
        
{
            
get
            
{
                
return new NetworkCredential(userName, password, domain);
            }

        }

2. 在页面上添加ReportViewer控件,设置属性:

          <rsweb:ReportViewer ID="ctl_rv_Report" runat="server" Font-Names="Verdana" Font-Size="8pt"
            Height
="400px" ProcessingMode="Remote" ShowToolBar="False" Width="100%" AsyncRendering="False" InternalBorderColor="Transparent" PromptAreaCollapsed="True" ShowParameterPrompts="False">
            
<ServerReport ReportPath="/Folder/Name" ReportServerUrl="http://site/reportserver" />
        
</rsweb:ReportViewer>

主要的是ProcessingMode="Remote",有两种模式,另外一种是Local。如果是Local,下面就是<LocalReport.....
另外重要的是ReportPath和ReportServerUrl,设置正确。
3. 代码:

        protected void Page_Load(object sender, EventArgs e)
        
{
            
if (!IsPostBack)
            
{
                ReportCredential report 
= new ReportCredential();
                ctl_rv_Report.ServerReport.ReportServerCredentials 
= report;

            IList
<ReportParameter> parms = new List<ReportParameter>();
            ReportParameter p 
= new ReportParameter("LocationsLocationID""[Locations].[Location ID].&[" + LocationID + "]");
            parms.Add(p);

            ctl_rv_Report.ServerReport.SetParameters(parms);
            }

        }

设置验证,report是实现了接口的类的一个实例,

                ReportCredential report = new ReportCredential();
                ctl_rv_Report.ServerReport.ReportServerCredentials 
= report;

添加参数,根据report service里的report情况添加参数:

            IList<ReportParameter> parms = new List<ReportParameter>();
            ReportParameter p 
= new ReportParameter("LocationsLocationID""[Locations].[Location ID].&[" + LocationID + "]");
            parms.Add(p);

            ctl_rv_Report.ServerReport.SetParameters(parms);

可以在某个postback后设置参数,比如点击button,dropdownlist selectedindexchanged事件,只有设置了参数后,reportViewer控件才会将RS中的结果显示在页面上了。