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. JAVA Stack栈和Heap堆的区别(转)

          首先分清楚Stack,Heap的中文翻译:Stack—栈,Heap—堆.         在中文里,Stack可以翻译为“堆栈”,所以我直接查找了计算机术语里面堆和栈开头的词语:      ...

  2. 查看Linux系统下Raid信息

    软件raid:只能通过Linux系统本身来查看 cat /proc/mdstat 可以看到raid级别,状态等信息. 硬件raid: 最佳的办法是通过已安装的raid厂商的管理工具来查看,有cmdli ...

  3. Eclipse自动补全功能轻松设置 || 不需要修改编辑任何文件

    本文介绍如何设置Eclipse代码自动补全功能.轻松实现输入任意字母均可出现代码补全提示框.   Eclipse代码自动补全功能默认只包括 点"."  ,即只有输入”." ...

  4. SQL查询最近三个月的数据(查询最近几天,几年等等)

    定义和用法      :: 天,这样就可以找到付款日期. 我们使用如下 ,OrderDate) AS OrderPayDate FROM Orders 结果: OrderId    OrderPayD ...

  5. 《Two Days DIV + CSS》读书笔记——CSS控制页面方式

    1.1 你必须知道的知识 (其中包括1.1.1 DIV + CSS的叫法解释:1.1.2 DIV + CSS 名字的误区:以及1.1.3 W3C简介.由于只是背景知识,跳过该章.) 1.2 你必须掌握 ...

  6. WifiDog系统

    WifiDog:A captive portal suite What is it composed of ? A: It is composed of 2 components: The clien ...

  7. C语言漫谈(二) 图像显示 Windows和Linux

    关于图像显示有很多库可以用,Windows下有GDI,GDI+,D3D等,Linux下有X Window和Wayland,此外还有OpenGL ,SDL等图形库以及各种GUI库. 了解最原始的方式,对 ...

  8. java与.net比较学习系列(6) 数组

    这一篇文章要总结的内容是数组,数组可以简单地看成是同种数据类型变量的集合,它在我们的开发中经常用到,我们主要从以下几个方面进行总结: 1,数组的创建和初始化 2,数组的访问和遍历 3,数组的总结 数组 ...

  9. 奇妙的go语言(聊天室的开发)

    [ 声明:版权全部,欢迎转载,请勿用于商业用途.  联系信箱:feixiaoxing @163.com] 这是一篇关于聊天室开发的博客,原来文章的地址来自于此.这篇文章非常具有代表性,对于代码中的函数 ...

  10. jquery使用load开展局部刷新没有效果

    jquery使用load开展局部刷新没有效果   jquery使用load进行局部刷新没有效果我的代码 <html><head><meta charset="u ...