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

推荐订阅源

A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
N
News and Events Feed by Topic
C
Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog
量子位
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
AWS News Blog
AWS News Blog
爱范儿
爱范儿
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
L
LINUX DO - 最新话题
Security Archives - TechRepublic
Security Archives - TechRepublic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
Cloudbric
Cloudbric
aimingoo的专栏
aimingoo的专栏
L
Lohrmann on Cybersecurity
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hacker News: Ask HN
Hacker News: Ask HN
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
S
Security @ Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
P
Proofpoint News Feed
V
V2EX
Martin Fowler
Martin Fowler
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Cloudflare Blog
SecWiki News
SecWiki News
罗磊的独立博客
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
The Last Watchdog
The Last Watchdog

博客园 - 蒜头

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中的结果显示在页面上了。