转:Dynamic Binding Of RDLC To ReportViewer
Introduction
I was struggling to find the solution to bind rdlc dynamically to reportviewer .We had a scenario were we migrated our application from .NET 1.1 to .NET 2.0 .After migration embedding reportviewer with explicit objectdatasource was creating a major issue. Whenever we try to assign dataset reference to objectdatasource the IDE shuts down abruptly for no reason. This was one of the bug we encountered while developing. We searched a lot but this unique problem was faced by very few hence the correct solution was not available. We then planned to bind the reportviewer at runtime without taking objectdatasource. Below is the procedure to go about it.
Design Architecture

Production Deployment Issues And Its Resolution
During deployment if the source code is published and precompiled is created, one has to be extra careful to do below activity.
- Create precompiled for deployment.
- Replace the .RDLC file from the precompiled source code with the original *.rdlc file. The reason behind this is precompiled corrupt the .rdlc internal code constructs. In order to maintain its schema and design we suggest you to replace the precompiled rdlc with original one.
Prerequisite
Note: In production web server we have light weight .net framework installed so report viewer is not available. Due to which it will throw report viewer dlls not exist.
Click here to install Reportviewer.exe.
Problem Statement
There is customer table with two field customerid and customerName. We need to generate report for this datatable in reportviewer without usingobjectdatasource.
Create Dataset Schema
Follow the step given below to define dataset schema without connecting to any datasource. This is manual process. This is require each column of the table to added one by one as shown below.

Click on the toolbox icon to proceed further.

Add column to the schema as given below.

Create Report RDLC With Parameter
One needs to drag table from toolbox to panel to draw table section as body part of report. Once done that click on Show Data Source one will view the dataset schema section as given below. Drag columns into table row just below header section. Select Reportparameter from main menu and add one to report. This parameter value can be passed from aspx's form to Reportviewer's RDLC panel.

Drag textbox in report screen and right click to select property of it.

Click on Fx button of value field to associate this textbox field value to parameter set field variable.


Embed Report Viewer in Aspx
Drag Reportviewer into aspx design page and add localpath of the RDLC file. One can invoke storeprocedure and get the database resultset and can assign it to reportviewer. For running a version of this demo, I included hardcoded resultset.
Collapseprivate void BindReportViewer()
{
ReportViewer1.Visible = true; //Invoke Stored procedure With Input parameter to it.
//DataSet dsReport = objSP.GetTable(storedProcedure,txtParameter.Text));
//Hardcoded Values.
IList >Customer< customerList = new List>Customer<();
customerList.Add(new Customer(1,"Santosh Poojari"));
customerList.Add(new Customer(2, "Santosh Poojari1"));
customerList.Add(new Customer(3, "Santosh Poojari2")); ReportParameter[] param = new ReportParameter[1];
param[0] = new ReportParameter("Report_Parameter_0",txtParameter.Text);
ReportViewer1.LocalReport.SetParameters(param); ReportDataSource rds = new ReportDataSource
("DataSet1_Customers_DataTable1", customerList);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
Below is the expected output.

Conclusion
Hope this article will help those who are working on similar problem statement. Any suggestion and advice will help me to improve the quality of this article.
转:Dynamic Binding Of RDLC To ReportViewer的更多相关文章
- java之多态(Polymorphic)、动态绑定(Dynamic Binding)、迟绑定(Late Binding)
今天,我们来说说java面向对象最核心的东西,多态.通过多态可以使我们的程序可复用性达到极致,这就是我们为什么要学多态的原因. “多态”(Polymorphic)也叫“动态绑定”(Dynamic Bi ...
- Dynamic Binding & Static Binding
Reference: JavaPoint BeginnerBook What is Binding Connecting a method call to the method body is kno ...
- Dynamic Binding
调用方法时,如何决定调用对象还是其父类的方法呢? 在JVM中,根据实际类型(actual type)调用.而非声明类型(declared type),如果实际类型的类中没有该方法,就会沿着inheri ...
- Java中对象方法的调用过程&动态绑定(Dynamic Binding)
Java面向对象的最重要的一个特点就是多态, 而多态当中涉及到了一个重要的机制是动态绑定(Dynamic binding). 之前只有一个大概的概念, 没有深入去了解动态绑定的机理, 直到很多公司都问 ...
- static binding/dynamic binding
static binding/dynamic binding class Person { private void who() { System.out.println("Inside p ...
- Only Link: What's the difference between dynamic dispatch and dynamic binding
http://stackoverflow.com/questions/20187587/what-is-the-difference-between-dynamic-dispatch-and-late ...
- ASP.NETserver控件使用之Reportviewer 报表
1. Reportviewer 报表 1.1. Reportviewer控件 注:本教程附2个事例: l 演练:在本地处理模式下将数据库数据源与 ReportViewer W ...
- Dynamic dispatch
Dynamic dispatch动态调度.动态分发 In computer science, dynamic dispatch is the process of selecting which im ...
- mvc 在view视图中直接输出rdlc报表文件(Excel、PDF、Word)
给一段代码做参考 public ActionResult RdlcReport(string code) { LocalReport localReport = new LocalReport(); ...
随机推荐
- linux awk 使用
awk是linux下的一个命令,他对其他命令的输出,对文件的处理都十分强大,其实他更像一门编程语言,他可以自定义变量,有条件语句,有循环,有数组,有正则,有函数等.他读取输出,或者文件的方式是一行,一 ...
- 关于导入oracle10g的数据到sqlserver2005里的方案总结
由于项目需求,现需要将oracle的数据全部导入到sqlserver中,一下算是自己的总结小计吧. sqlserver有自己的导入数据的功能,其中就有提供两种方式从oracle导入数据. 两种方式就不 ...
- 单路CPU性能排名 更新于2015.10.6
http://itianti.sinaapp.com/index.php/cpu 排名 处理器 图例 分数 1 Intel Xeon E5-2699 v3 @ 2.30GHz 22892 2 Inte ...
- 2013第50周二eclipse工具尝试
今天更深入的认识了eclipse开发工具,出现了各种问题在网络的帮助下最终都解决了,感觉似乎明白了很多道理需要总结一下,现在发现晚了,那就先记录下我印象深的几个问题吧: 1.eclipse编辑器设置. ...
- LDA-线性判别分析(一)
本来是要调研 Latent Dirichlet Allocation 的那个 LDA 的, 没想到查到很多关于 Linear Discriminant Analysis 这个 LDA 的资料.初步看了 ...
- java获取文件大小
1.使用File的length()方法获取.这个方法获取的字节数,由于返回的是Long类型所以能返回的最大值是Long.MAX_VALUE File file = new File( "D: ...
- [汇编学习笔记][第十七章使用BIOS进行键盘输入和磁盘读写
第十七章 使用BIOS进行键盘输入和磁盘读写 17.1 int 9 中断例程对键盘输入的处理 17.2 int 16 读取键盘缓存区 mov ah,0 int 16h 结果:(ah)=扫描码,(al) ...
- 数组,集合 转成DataTable 方法
public static DataTable ToDataTable(IList p_List) { DataTable _DataTable = new DataTable(); if (p_Li ...
- Mob短信验证的配置的解释
原文地址:http://www.jb51.net/article/84946.htm 关于mob短信验证的解释: mob官方是这样写的: repositories{ flatDir{ dirs 'li ...
- 提示框的优化之自定义Toast组件之(三)Toast组件优化
开发步骤: 在toast_customer.xml文件中添加一个图片组件对象显示提示图片 <?xml version="1.0" encoding="utf-8&q ...