转: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(); ...
随机推荐
- Magento How To Display Product Custom Option On list.phtml
Some time we need to display custom option of product on category list page to achive this task we o ...
- centos 6.4 更新源地址
执行如下命令: mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.old vim /etc/yum.repo ...
- C++默认构造函数的一点说明
大多数C++书籍都说在我们没有自己定义构造函数的时候,编译器会自动生成默认构造函数.其实这句话我一直也是 深信不疑.但是最近看了一些资料让我有了一点新的认识. 其实我觉得大多数C++书籍之所以这样描述 ...
- JUnit单元测试框架的使用
http://blog.csdn.net/mao520741111/article/details/51462215 原文地址 http://www.open-open.com/lib/view/op ...
- hdu 3711 Binary Number(暴力 模拟)
Problem Description For non-negative integers x and y, f(x, y) , )=,f(, )=, f(, )=. Now given sets o ...
- thinkphp 一些常用写法
多表查询:
- [转]XNOR-Net ImageNet Classification Using Binary Convolutional Neural Networks
感谢: XNOR-Net ImageNet Classification Using Binary Convolutional Neural Networks XNOR-Net ImageNet Cl ...
- ABAP - 日期格式转换 & ABAP经常使用日期处理函数
ABAP - 日期格式转换 如今提供下面一些日期格式转换的函数: Below are several FMs which can be used to convert date format. 1. ...
- Java里多个Map的性能比較(TreeMap、HashMap、ConcurrentSkipListMap)
问题 比較Java原生的 1. TreeMap 2. HashMap 3. ConcurrentSkipListMap 3种Map的效率. 结果 模拟150W以内海量数据的插入和查找,通过添加和 ...
- codevs1009
题目地址:http://codevs.cn/problem/1009/ 分析: [TAG]FLOYD,乘法原理,高精度 [构思] 求可变换数的个数,那么就是组合数学的内容,四个原理的应用: 假如能知道 ...