📄 reportviewerdemo.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Diagnostics;
using System.Text;
using AWC.Reporter.Web.RS;
namespace AWC.Reporter.Web
{
/// <summary>
/// Summary description for ReportViewer.
/// </summary>
public class ReportViewerDemo : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drpReports;
protected System.Web.UI.WebControls.DropDownList drpExport;
protected System.Web.UI.WebControls.LinkButton lnkRun;
protected Microsoft.Samples.ReportingServices.ReportViewer reportViewer;
private void Page_Load(object sender, System.EventArgs e)
{
if (!this.IsPostBack)
{
LoadExportFormats();
LoadReports();
ShowReport();
}
}
/// <summary>
/// Load the reports from the report catalog
/// </summary>
private void LoadReports()
{
ReportingService rs = RsHelpers.Proxy; CatalogItem[] items = null;
try
{
items = rs.ListChildren(ConfigurationSettings.AppSettings[Constants.CONFIG_REPORT_FOLDER], false);
}
catch (System.Exception ex)
{
throw ex;
}
// enumerate through the catalog items and filter out the reports only
foreach (CatalogItem item in items)
{
if (item.Type == ItemTypeEnum.Report) drpReports.Items.Add (new ListItem(item.Name,item.Path));
}
}
/// <summary>
/// Load the Export Formats
/// </summary>
private void LoadExportFormats()
{
ReportingService rs = RsHelpers.Proxy;
Extension[] extensions = null;
// Retrieve a list of all supported rendering extensions.
try
{
extensions = rs.ListExtensions(ExtensionTypeEnum.Render);
if (extensions != null)
{
foreach (Extension extension in extensions)
{
if (extension.Name.ToLower()!="null") drpExport.Items.Add(new ListItem(extension.Name));
}
drpExport.Items.FindByText("HTML4.0").Selected = true;
}
}
catch (System.Exception ex)
{
throw ex;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lnkRun.Click += new System.EventHandler(this.lnkRun_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void lnkRun_Click(object sender, System.EventArgs e)
{
ShowReport();
}
private void ShowReport()
{
reportViewer.ReportPath = drpReports.SelectedValue;
reportViewer.Format = drpExport.SelectedValue;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -