473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C#, ReportViewer and RDLC - How to use many RDLC in one ReportViewer

6
Hi all,

I am sorry if I have posted this problem to irrelevant forum. I am working in C#, and I don't find any C# forum here. I hope someone here can help me to resolve my problem. Here is:

I am working by using VS2005 and dotNet Framework 2.0. I have an ASP Content page, with one ReportViewer, and 5 RDLC files. This page contains a dropdownlist with 5 items, which if someone choose any one of them, they will see the report on the bottom of the page. The problem is occurred when someone choose other report after they have chosen a report.. hmm.. I mean like this, firstly you choose report A. You will see the right report. Then you choose other report (B or C or D or anything except A), you will see a wrong report. The problem is: you will get the right data but wrong RDLC. The first RDLC will be always used for other report.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1. (something.aspx.cs)
  2.  
  3. using System;
  4. using System.Data;
  5. using System.Configuration;
  6. using System.Collections;
  7. using System.Web;
  8. using System.Web.Security;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Web.UI.HtmlControls;
  13. using Netway.CMS.F1.Web.App_Code;
  14.  
  15. using Microsoft.Reporting.WebForms;
  16.  
  17. namespace Netway.CMS.F1.Web.Web.CMC1141
  18. {
  19.     public partial class PBLaporanLunasKuitansi : System.Web.UI.Page
  20.     {
  21.         private void FillRptTitle()
  22.         {
  23.              this.cboReportTitle.Items.Clear();
  24.             this.cboReportTitle.Items.Add(new ListItem("Detil Pelunasan Kuitansi PB", "0"));
  25.             this.cboReportTitle.Items.Add(new ListItem("Rekap Pelunasan Kuitansi PB", "1"));
  26.             this.cboReportTitle.Items.Add(new ListItem("Ikhtisar Pelunasan BP dan UJL Per Tarif", "2"));
  27.             this.cboReportTitle.Items.Add(new ListItem("Daftar Pembayaran BP dan UJL", "3"));
  28.             this.cboReportTitle.Items.Add(new ListItem("Rekap Penerimaan BP dan UJL", "4"));
  29.         }
  30.         protected void Page_Load(object sender, EventArgs e)
  31.         {
  32.             if (!IsPostBack)
  33.             {
  34.                 //bindAllControl();
  35.                 FillRptTitle();
  36.             }
  37.         }
  38.  
  39.         protected void btnPreview_Click(object sender, EventArgs e)
  40.         {
  41.             string strDateFrom = tbxDateFrom.Text;
  42.             string strDateTo = tbxDateTo.Text;
  43.             string strBlTh = tbxBlTh.Text;
  44.             int intJenisLap = int.Parse(cboReportTitle.SelectedValue);
  45.             LunasKuitansiPBController lkpbc = new LunasKuitansiPBController();
  46.             lkpbc.RvLapLunasKuitPB = viewerLapLunasKuitPB;
  47.             lkpbc.TbxDateFrom = tbxDateFrom;
  48.             lkpbc.TbxDateTo = tbxDateTo;
  49.             lkpbc.TbxBlTh = tbxBlTh;
  50.             lkpbc.PreviewLaporan(strDateFrom, strDateTo, strBlTh, intJenisLap);
  51.         }
  52.  
  53.         protected void bindAllControl()
  54.         {
  55.             LunasKuitansiPBController lkpbc = new LunasKuitansiPBController();
  56.             lkpbc.RvLapLunasKuitPB = viewerLapLunasKuitPB;
  57.         }
  58.     }
  59. }
  60.  
Expand|Select|Wrap|Line Numbers
  1. (some code in LunasKuitansiPBController.cs)
  2.  
  3.         public void PreviewLaporan(string strDateFrom, string strDateTo, string strBlTh, int intJenisLap)
  4.         {
  5.             Hashtable htData = new Hashtable();
  6.             htData.Add("parFromDate", strDateFrom);
  7.             htData.Add("parToDate", strDateTo);
  8.             htData.Add("parBlTh", strBlTh);
  9.             //throw new ApplicationException("strFromDate: " + strDateFrom + " strToDate: " + strDateTo);
  10.             switch (intJenisLap)
  11.             {
  12.                 #region catatan
  13.                 //this.cboReportTitle.Items.Add(new ListItem("Detil Pelunasan Kuitansi PB", "0"));
  14.                 //this.cboReportTitle.Items.Add(new ListItem("Rekap Pelunasan Kuitansi PB", "1"));
  15.                 //this.cboReportTitle.Items.Add(new ListItem("Ikhtisar Pelunasan BP dan UJL Per Tarif", "2"));
  16.                 //this.cboReportTitle.Items.Add(new ListItem("Daftar Pembayaran BP dan UJL", "3"));
  17.                 //this.cboReportTitle.Items.Add(new ListItem("Rekap Penerimaan BP dan UJL", "4"));
  18.                 #endregion
  19.                 case 0:
  20.                     DetilLunasKuitPB(htData);
  21.                     break;
  22.                 case 1:
  23.                     RekapLunasKuitPB(htData);
  24.                     break;
  25.                 case 2:
  26.                     IkhtisarBPUJL(htData);
  27.                     break;
  28.                 case 3:
  29.                     DaftarBPUJL(htData);
  30.                     break;
  31.                 case 4:
  32.                     RekapBPUJL(htData);
  33.                     break;
  34.             }
  35.         }
  36.  
  37.         private void DetilLunasKuitPB(Hashtable htData)
  38.         {
  39.             ReportDataSource rds0 = new ReportDataSource();
  40.             rds0.Name = "Netway_CMS_F1_Data_Domain_Reports_LapLunasKuitPB";
  41.             IList<LapLunasKuitPB> listmu = getLaporan(0, htData);
  42.             rds0.Value = listmu;
  43.  
  44.             _rvLapLunasKuitPB.LocalReport.DataSources.Clear();
  45.             _rvLapLunasKuitPB.LocalReport.DataSources.Add(rds0);
  46.  
  47.             _rvLapLunasKuitPB.LocalReport.ReportPath = "Netway.CMS.F1.Web\\Web\\CMC1141\\Reports\\RptPBLunasKuitansiDetil.rdlc";
  48.             //_rvLapLunasKuitPB.LocalReport.ReportEmbeddedResource = "Netway.CMS.F1.Web.Web.CMC1141.Reports.RptPBLunasKuitansiDetil.rdlc";
  49.  
  50.             string strFromDate = htData["parFromDate"].ToString();
  51.             string strToDate = htData["parToDate"].ToString();
  52.             //throw new ApplicationException("strFromDate: " + strFromDate + " strToDate: " + strToDate);
  53.  
  54.             ReportParameter parFromDate = new ReportParameter("parFromDate", strFromDate);
  55.             ReportParameter parToDate = new ReportParameter("parToDate", strToDate);
  56.             this._rvLapLunasKuitPB.LocalReport.SetParameters(new ReportParameter[] { parFromDate, parToDate });
  57.  
  58.             _rvLapLunasKuitPB.LocalReport.Refresh();
  59.  
  60.         }
  61.  
  62.         private void RekapLunasKuitPB(Hashtable htData)
  63.         {
  64.             ReportDataSource rds = new ReportDataSource();
  65.             rds.Name = "Netway_CMS_F1_Data_Domain_Reports_LapLunasKuitPB";
  66.             IList<LapLunasKuitPB> list = getLaporan(1, htData);
  67.             rds.Value = list;
  68.  
  69.             _rvLapLunasKuitPB.LocalReport.DataSources.Clear();
  70.             _rvLapLunasKuitPB.LocalReport.DataSources.Add(rds);
  71.  
  72.             _rvLapLunasKuitPB.LocalReport.ReportPath = "Netway.CMS.F1.Web\\Web\\CMC1141\\Reports\\RptPBLunasKuitansiRekap.rdlc";
  73.             //_rvLapLunasKuitPB.LocalReport.ReportEmbeddedResource = "Netway.CMS.F1.Web.Web.CMC1141.Reports.RptPBLunasKuitansiRekap.rdlc";
  74.  
  75.             string strFromDate = htData["parFromDate"].ToString();
  76.             string strToDate = htData["parToDate"].ToString();
  77.  
  78.             ReportParameter parFromDate = new ReportParameter("parFromDate", strFromDate);
  79.             ReportParameter parToDate = new ReportParameter("parToDate", strToDate);
  80.             this._rvLapLunasKuitPB.LocalReport.SetParameters(new ReportParameter[] { parFromDate, parToDate });
  81.  
  82.             _rvLapLunasKuitPB.LocalReport.Refresh();
  83.  
  84.         }
  85.  
  86.         private IList<LapLunasKuitPB> getLaporan(int intJenisLap, Hashtable htData)
  87.         {
  88.             LunasKuitansiPBService lkpbs = new LunasKuitansiPBService();
  89.             switch (intJenisLap)
  90.             {
  91.                 case 0:
  92.                     return lkpbs.LapDetilLunasKuitPB(htData);
  93.                     //break;
  94.                 case 1:
  95.                     return lkpbs.LapRekapLunasKuitPB(htData);
  96.                     //break;
  97.                 case 2:
  98.                     return lkpbs.LapIkhtisarBPUJLPB(htData);
  99.                     //break;
  100.                 case 3:
  101.                     return lkpbs.LapDaftarBPUJLPB(htData);
  102.                     //break;
  103.                 case 4:
  104.                     return lkpbs.LapRekapBPUJLPB(htData);
  105.                     //break;
  106.                 default:
  107.                     return lkpbs.LapDetilLunasKuitPB(htData);
  108.                     //break;
  109.             }
  110.         }
  111.  
  112.  
Expand|Select|Wrap|Line Numbers
  1. (some code in LunasKuitansiPBService.cs)
  2.  
  3.         public IList<LapLunasKuitPB> LapDetilLunasKuitPB(Hashtable htData)
  4.         {
  5.             return Mapper.Instance().QueryForList<LapLunasKuitPB>("CMC1141.prevPBLunasDetil", htData);
  6.         }
  7.  
  8.         public IList<LapLunasKuitPB> LapRekapLunasKuitPB(Hashtable htData)
  9.         {
  10.             return Mapper.Instance().QueryForList<LapLunasKuitPB>("CMC1141.prevPBLunasRekap", htData);
  11.         }
  12.  
  13.  
Could you please help me? Thanks.


Regards,
Novan Ananda
Feb 20 '08 #1
1 19296
You just need to Reset the reportviewer between each change of RDLC :
_rvLapLunasKuitPB.Reset()
Sep 9 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: steve | last post by:
Hi All I need help on how to manipulate the data returned from the database for displaying in the new reportviewer at runtime So far I have an rdlc file with a dataset, binding source and...
1
by: Rich | last post by:
Hello, I am trying to use the Reportviewer control. I have been following an example from the web, and the instructions from the help files on set up a ..rdlc and binding it to the reportviewer...
0
by: billygotee | last post by:
Hi, I posted an issue previously that was entirely accurate. I have a master report called "MasterReport.rdlc" and a subreport called "Subreport.rdlc". MasterReport.rdlc has a single subreport...
0
jgroos
by: jgroos | last post by:
Here is my scenario: I have two different reports processed LOCALLY, lets say Report1.rdlc and Report2.rdlc. They both are populated with data from a database, and they both also take a list of...
10
by: AG | last post by:
I am trying to use a ReportViewer control in a VS 2005 web application project (not Website project). When I try to create a new report (local), I can't seem to find any method to create a...
1
by: Larry Bud | last post by:
I have a reportviewer control. I programmatically set the local report path based on a drop down on a page. This allows the user to choose which format (RDLC file) to use when generating the...
0
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello Gurus, I produced an RDLC file with 3 tables. My application holds a DataSet with 3 kind of tables. I'm generating Visual Studio 2005 report for the 3 tables in the DataSet. I'm using the...
1
by: Wendi Turner | last post by:
Configuration Error from Visual Studio 2005 .NET 2.0 This is an ASP.NET Website with a Report Viewer Component - Microsoft.ReportViewer.WebForms & .Common included in project output Trying to...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a VS 2008 ASP.NET webform that has a reportview tag on it, accessing an .RLDC report in local report. The columns for the report are essentially: Month Item #1 Item#2 Item#3 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.