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> &nbsp;&nbsp;&nbsp; 兑奖时间:
<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使用的更多相关文章

  1. [Ext JS 4] 实战之 带week(星期)的日期选择控件(三)

    前言 在 [Ext JS 4] 实战之 带week(星期)的日期选择控件(二) 的最后,有提到一个解决方案. 不过这方案有一个条件  ==> “2. 每年的周数从(1-52), 如果超过52 周 ...

  2. 学习懈怠的时候,可以运行Qt自带的Demo,或者Delphi控件自带的Demo,或者Cantu书带的源码,运行一下Boost的例子(搞C++不学习Boost/Poco/Folly绝对是一大损失,有需要使用库要第一时间想到)(在六大的痛苦经历说明,我的理论性确实不强,更适合做实践)

    这样学还不用动脑子,而且熟悉控件也需要时间,而且慢慢就找到感觉了,就可以精神抖擞的恢复斗志干活了.或者Cantu书带的源码. 并且可以使用Mac SSD运行Qt的Demo,这样运行速度快一点. 此外, ...

  3. 一个带展示的jsp上传控件模型

    带展示上传控件的基本模型,无样式 jsp部分: <td> <form id="form1" enctype="multipart/form-data&q ...

  4. 【Android】带底部指示的自定义ViewPager控件

    在项目中经常需要使用轮转广告的效果,在android-v4版本中提供的ViewPager是一个很好的工具,而一般我们使用Viewpager的时候,都会选择在底部有一排指示物指示当前显示的是哪一个pag ...

  5. VS2015中使用报表控件(ReportViewer)的方法

    没有报表,一般默认安装之后会出现这种情况,在安装的时候选择自定义安装,把Microsoft Office 开发人员工具.Microsoft SQL Server Data Tools勾选上,安装之后就 ...

  6. [Ext JS 4] 实战之 带week(星期)的日期选择控件

    前言 Ext JS 3 和 Ext JS 4中都有提供日期选择的组件(当然早期版本也有). 但是有一些日期选择的需求是要看到星期,就是日期中的哪一天是这一年的第几周. 遗憾的是Ext js 并没有提供 ...

  7. 实现带复选框的TreeView控件

    实现效果: 知识运用: TreeView控件的CheckView属性 //是否在树形视图控件中显示复选框 public bool CheckBoxs{ get;ser } 实现代码: TreeView ...

  8. 制作带复选框的ListView控件

    实现效果: 知识运用   ListView控件的GridLines //设置是否在ListView控件中显示网格线 public bool GridLines{get;set} 和CheckBoxes ...

  9. C#线程调用带参数的方法,给控件赋值

    System.Threading.Thread thread = new System.Threading.Thread(() => { //各种业务 //定义一个委托 public deleg ...

随机推荐

  1. Linux目录结构及常用命令(转载)

    一.Linux目录结构 你想知道为什么某些程序位于/bin下,或者/sbin,或者/usr/bin,或/usr/sbin目录下吗?例如,less命令位于/usr/bin目录下.为什么没在/bin中,或 ...

  2. 自动切换的JS菜单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > <html xmlns=&quo ...

  3. SQL Server 2005 发布 订阅 (配置实例[图])(转载)

    2.1          发布&订阅 1.       测 试环境: Item 发布机 A 订阅机 B OS Windows 2003 Server Windows 2003 Server S ...

  4. myBatis 实现用户表增操作(复杂型)

    增加 @Test public void addTest(){ String resource = "mybatis-config.xml"; SqlSession sqlSess ...

  5. angular-ngSanitize模块-linky过滤器详解

    本篇主要讲解angular中的linky这个过滤器.此过滤器依赖于ngSanitize模块. linky能找出文本中的链接,然后把它转换成html链接.什么意思,就是说,一段文本里有一个链接,但是这个 ...

  6. motto7

    与其羡慕别人,还不如模仿别人的过程.

  7. 如何设置通过ip访问数据库

    文章转自:http://blog.163.com/wz_pk007/blog/static/17062705020119242440713/ 问题:mysql只能用localhost或127.0.0. ...

  8. 为自己的git添加alias,命令缩写

    在多人协作开发时,一般用git来进行代码管理.git有一些命令如:git pull . git push等等,这些命令可以设置alias,也就是缩写.如:git pull 是 git pl, git ...

  9. notepad正则表达式

    文件名称匹配 文件名称: boost_chrono-vc100-mt-1_49.dll 对应的notepad正则表达式: \w*_\w*-\w*-\w*-\w*-\w*.dll 移除空行 查找目标: ...

  10. luarocks install with lua5.1 and luajit to install lapis

    # in luarocks source directory...git clone https://github.com/archoncap/luarockscd luarocks ./config ...