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.

 Collapse
 private 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的更多相关文章

  1. java之多态(Polymorphic)、动态绑定(Dynamic Binding)、迟绑定(Late Binding)

    今天,我们来说说java面向对象最核心的东西,多态.通过多态可以使我们的程序可复用性达到极致,这就是我们为什么要学多态的原因. “多态”(Polymorphic)也叫“动态绑定”(Dynamic Bi ...

  2. Dynamic Binding & Static Binding

    Reference: JavaPoint BeginnerBook What is Binding Connecting a method call to the method body is kno ...

  3. Dynamic Binding

    调用方法时,如何决定调用对象还是其父类的方法呢? 在JVM中,根据实际类型(actual type)调用.而非声明类型(declared type),如果实际类型的类中没有该方法,就会沿着inheri ...

  4. Java中对象方法的调用过程&动态绑定(Dynamic Binding)

    Java面向对象的最重要的一个特点就是多态, 而多态当中涉及到了一个重要的机制是动态绑定(Dynamic binding). 之前只有一个大概的概念, 没有深入去了解动态绑定的机理, 直到很多公司都问 ...

  5. static binding/dynamic binding

    static binding/dynamic binding class Person { private void who() { System.out.println("Inside p ...

  6. 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 ...

  7. ASP.NETserver控件使用之Reportviewer 报表

    1.       Reportviewer 报表 1.1.       Reportviewer控件 注:本教程附2个事例: l  演练:在本地处理模式下将数据库数据源与 ReportViewer W ...

  8. Dynamic dispatch

    Dynamic dispatch动态调度.动态分发 In computer science, dynamic dispatch is the process of selecting which im ...

  9. mvc 在view视图中直接输出rdlc报表文件(Excel、PDF、Word)

    给一段代码做参考 public ActionResult RdlcReport(string code) { LocalReport localReport = new LocalReport(); ...

随机推荐

  1. Square spiral

    Square spiral Nikola picks up a strange circuit board. All of its elements are connected in a spiral ...

  2. structs2使用小结2

    回顾之前做过类似structs2的知识点总结 Structs2历史.处理流程及与1.0版本的区别 Structs2配置文件.拦截器.校验等 EL表达式在JS中使用 ${}El表达式不能直接在单独JS文 ...

  3. 【HDU1198】Farm Irrigation(回溯+记忆化搜索)

    数据流小,深搜即可.有些暴力.看其他人的题解用二维转换成一维做的并查集很巧妙,马上去研究一下!! #include <iostream> #include <cstring> ...

  4. SoftLayerDebug

  5. codevs 1001 舒适的路线 (并查集)

    题目描述 Description Z小镇是一个景色宜人的地方,吸引来自各地的观光客来此旅游观光. Z小镇附近共有 N(<N≤)个景点(编号为1,,,…,N),这些景点被M(<M≤)条道路连 ...

  6. Spring项目的建立-移植流程(非入门教程)

    Creat by Zhou yong in 2016/4/15/19:00 jar包 java 1.7 tomcat的两个jar包 2个文件上传的jar包 json支持的jar包 hibernate- ...

  7. [HeadFist-HTMLCSS学习笔记][第五章认识媒体]

    图像格式 PNG 多种颜色透明 无损压缩 PNG-8,PNG-16,PNG-32 多用于logo GIF 动画 256色 无损 JPEG 不能透明 多用于照片 img URL能插入 alt属性 = 如 ...

  8. 《JavaScript 闯关记》之原型及原型链

    原型链是一种机制,指的是 JavaScript 每个对象都有一个内置的 __proto__ 属性指向创建它的构造函数的 prototype(原型)属性.原型链的作用是为了实现对象的继承,要理解原型链, ...

  9. LESS使用方法简介(装逼神器)

    LESS 做为 CSS 的一种形式的扩展,它并没有阉割 CSS 的功能,而是在现有的 CSS 语法上,添加了很多额外的功能,所以学习 LESS 是一件轻而易举的事情,果断学习之! 变量 很容易理解: ...

  10. Android--------Java接口回调

    >###回调说明 回调说明:         1.class A,class B         2.class A 实现接口callback         3.class B拥有一个参数为c ...