使用VS自带的报表RDLC结合报表控件ReportViewer使用
1.新建一个报表,设置报表之后,使用强类型的DataSet xsd 配置数据源,对报表中的使用最常用的是文本框和表格控件
2.新增WebForm窗体,拖一个ReportViewer控件,在WebForm中写入以下代码:
WebForm html:
- <%@ Page Language="C#" MasterPageFile="~/Site_admin.Master" AutoEventWireup="true" CodeBehind="LotteryBill.aspx.cs" Inherits="XieYun.WebAdmin.ReportsALL.Organization.LotteryBill" %>
- <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
- <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
- </asp:Content>
- <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
- <div>
- 兑奖时间:
- <input id="searchStarTime" runat="server" name="searchStarTime" data-options="showSeconds:false" class="easyui-datetimebox" style="width: 140px" />
- --
- <input class="easyui-datetimebox" runat="server" id="searchEndTime" name="searchEndTime" data-options="showSeconds:false" style="width: 140px" />
- <span>
- <asp:Button ID="btnSearch" runat="server" Text="查询" OnClick="btnSearch_Click" />
- </span>
- </div>
- <div>
- <rsweb:ReportViewer ID="reportViewer2" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="629px" Width="851px">
- </rsweb:ReportViewer>
- </div>
- </asp:Content>
使用ReportViewer时必须使用ScriptManager控件
后端代码
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!this.IsPostBack)
- {
- string strWhere = string.Format(" LotteryStatusEnum={0} and IsVirtual=0", (int)LotteryStatusEnum.TransferSuc);
- LoadReportData(strWhere);
- }
- }
- /// <summary>
- /// 加载报表数据
- /// </summary>
- /// <param name="strWhere"></param>
- private void LoadReportData(string strWhere)
- {
- reportViewer2.ProcessingMode = ProcessingMode.Local;
- reportViewer2.LocalReport.ReportEmbeddedResource = "XieYun.WebAdmin.ReportsALL.rdlc.LotteryBillReport.rdlc";
- LotteryRecordManager lotteryRecordManager = new LotteryRecordManager();
- int recordCount = ;
- List<LotteryRecordInfo> list = lotteryRecordManager.GetPageList(, int.MaxValue / , strWhere, "", out recordCount, false);
- if (list != null && list.Count > )
- {
- foreach (var info in list)
- {
- info.PrizeEnumStr = EnumValueNameDescriptionParse.GetEnumValueNameDescription(typeof(PrizeEnum), info.PrizeEnum).Description;
- info.PayEnumStr = EnumValueNameDescriptionParse.GetEnumValueNameDescription(typeof(PayEnum), info.PayEnum).Description;
- ;
- }
- }
- else
- {
- list = new List<LotteryRecordInfo>();
- }
- DataTable dt = lotteryRecordManager.ToDataTable2(list, "PrizeEnumStr", "PayEnumStr");
- if (dt == null)
- {
- dt = new DataTable();
- }
- ReportDataSource rds_shipperOrder = new ReportDataSource("DataSet1", dt);
- reportViewer2.LocalReport.DataSources.Clear();
- reportViewer2.LocalReport.DataSources.Add(rds_shipperOrder);
- reportViewer2.LocalReport.Refresh();
- }
- /// <summary>
- /// 单击搜索报表数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void btnSearch_Click(object sender, EventArgs e)
- {
- string searchStarTime = this.searchStarTime.Value;
- string searchEndTime = this.searchEndTime.Value;
- DateTime dtSearchStartTime;
- DateTime dtSearchEndTime;
- string strWhere = string.Format(" LotteryStatusEnum={0} and IsVirtual=0 ", (int)LotteryStatusEnum.TransferSuc);
- if (!string.IsNullOrWhiteSpace(searchStarTime)&&DateTime.TryParse(searchStarTime.Trim(),out dtSearchStartTime))
- {
- strWhere += string.Format(" AND TransferTime >='{0}' ",dtSearchStartTime);
- }
- if (!string.IsNullOrWhiteSpace(searchEndTime) && DateTime.TryParse(searchEndTime.Trim(), out dtSearchEndTime))
- {
- strWhere += string.Format(" AND TransferTime <='{0}' ", dtSearchEndTime);
- }
- LoadReportData(strWhere);
- }
使用VS自带的报表RDLC结合报表控件ReportViewer使用的更多相关文章
- [Ext JS 4] 实战之 带week(星期)的日期选择控件(三)
前言 在 [Ext JS 4] 实战之 带week(星期)的日期选择控件(二) 的最后,有提到一个解决方案. 不过这方案有一个条件 ==> “2. 每年的周数从(1-52), 如果超过52 周 ...
- 学习懈怠的时候,可以运行Qt自带的Demo,或者Delphi控件自带的Demo,或者Cantu书带的源码,运行一下Boost的例子(搞C++不学习Boost/Poco/Folly绝对是一大损失,有需要使用库要第一时间想到)(在六大的痛苦经历说明,我的理论性确实不强,更适合做实践)
这样学还不用动脑子,而且熟悉控件也需要时间,而且慢慢就找到感觉了,就可以精神抖擞的恢复斗志干活了.或者Cantu书带的源码. 并且可以使用Mac SSD运行Qt的Demo,这样运行速度快一点. 此外, ...
- 一个带展示的jsp上传控件模型
带展示上传控件的基本模型,无样式 jsp部分: <td> <form id="form1" enctype="multipart/form-data&q ...
- 【Android】带底部指示的自定义ViewPager控件
在项目中经常需要使用轮转广告的效果,在android-v4版本中提供的ViewPager是一个很好的工具,而一般我们使用Viewpager的时候,都会选择在底部有一排指示物指示当前显示的是哪一个pag ...
- VS2015中使用报表控件(ReportViewer)的方法
没有报表,一般默认安装之后会出现这种情况,在安装的时候选择自定义安装,把Microsoft Office 开发人员工具.Microsoft SQL Server Data Tools勾选上,安装之后就 ...
- [Ext JS 4] 实战之 带week(星期)的日期选择控件
前言 Ext JS 3 和 Ext JS 4中都有提供日期选择的组件(当然早期版本也有). 但是有一些日期选择的需求是要看到星期,就是日期中的哪一天是这一年的第几周. 遗憾的是Ext js 并没有提供 ...
- 实现带复选框的TreeView控件
实现效果: 知识运用: TreeView控件的CheckView属性 //是否在树形视图控件中显示复选框 public bool CheckBoxs{ get;ser } 实现代码: TreeView ...
- 制作带复选框的ListView控件
实现效果: 知识运用 ListView控件的GridLines //设置是否在ListView控件中显示网格线 public bool GridLines{get;set} 和CheckBoxes ...
- C#线程调用带参数的方法,给控件赋值
System.Threading.Thread thread = new System.Threading.Thread(() => { //各种业务 //定义一个委托 public deleg ...
随机推荐
- ios 关联对象运用 objc_setAssociatedObject
点按钮的时候,给alertView添加一个关联对象(被点击这个按钮), objc_setAssociatedObject(alert, &kRepresentedObject, sender, ...
- CentOS 设置网络(修改IP&修改网关&修改DNS)--update.14.08.15
自己电脑上装的虚拟机用桥接方式连接物理机,虚拟机重启后ip会发生变化,非常阻碍Xshell的连接和hosts指定的dns. 通过修改IP为static模式,保持IP不变. ============== ...
- WPF 数据绑定基础
纯理论,可能会枯燥. .net 技术群: 199281001 ,欢迎加入. 1.目标对象一定是派生自DependencyObject的对象,并且目标属性必须是依赖属性,否则数据绑定操作将会失 败. ...
- 未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage,
未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage, Microsoft.VisualStudio.Editor.Imp ...
- linux挂载硬盘失败,报错!
剛把我的一顆硬碟 ( NTFS ) 接到 Ubuntu 桌機上. 然後要 mount 的時候,出現了下面的訊息: DBus error org.gtk.Private.RemoteVolumeMon ...
- systemctl 命令的用法
对比表,以 apache / httpd 为例 任务 旧指令 新指令 使某服务自动启动 chkconfig --level 3 httpd on systemctl enable httpd.serv ...
- 在Sublime Text3 开发Node.js遇到的一个小问题
原文摘自我的前端博客,欢迎大家来访问 http://www.hacke2.cn 以前的Sublime Text 2包管理出现问题了,不能安装新包,让人开发很捉急,今天装了个3,这个问题解决了 那我们就 ...
- iOS工程如何支持64-bit(转)
苹果在2014年10月20号发布了一条消息:从明年的二月一号开始,提交到App Store的应用必须支持64-bit.详细消息地址为:https://developer.apple.com/news/ ...
- Hadoop集群(第1期)_CentOS安装配置
CentOS 是什么? CentOS是一个基于Red Hat 企业级 Linux 提供的可自由使用的源代码企业级的 Linux 发行版本.每个版本的 CentOS 都会获得七年的支持(通过安全更新方式 ...
- 文字编辑器kindeditor-min.js的使用
例子: <link rel="stylesheet" type="text/css" href="<?=$WebSiteRootDir?& ...