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
- (something.aspx.cs)
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using Netway.CMS.F1.Web.App_Code;
- using Microsoft.Reporting.WebForms;
- namespace Netway.CMS.F1.Web.Web.CMC1141
- {
- public partial class PBLaporanLunasKuitansi : System.Web.UI.Page
- {
- private void FillRptTitle()
- {
- this.cboReportTitle.Items.Clear();
- this.cboReportTitle.Items.Add(new ListItem("Detil Pelunasan Kuitansi PB", "0"));
- this.cboReportTitle.Items.Add(new ListItem("Rekap Pelunasan Kuitansi PB", "1"));
- this.cboReportTitle.Items.Add(new ListItem("Ikhtisar Pelunasan BP dan UJL Per Tarif", "2"));
- this.cboReportTitle.Items.Add(new ListItem("Daftar Pembayaran BP dan UJL", "3"));
- this.cboReportTitle.Items.Add(new ListItem("Rekap Penerimaan BP dan UJL", "4"));
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- //bindAllControl();
- FillRptTitle();
- }
- }
- protected void btnPreview_Click(object sender, EventArgs e)
- {
- string strDateFrom = tbxDateFrom.Text;
- string strDateTo = tbxDateTo.Text;
- string strBlTh = tbxBlTh.Text;
- int intJenisLap = int.Parse(cboReportTitle.SelectedValue);
- LunasKuitansiPBController lkpbc = new LunasKuitansiPBController();
- lkpbc.RvLapLunasKuitPB = viewerLapLunasKuitPB;
- lkpbc.TbxDateFrom = tbxDateFrom;
- lkpbc.TbxDateTo = tbxDateTo;
- lkpbc.TbxBlTh = tbxBlTh;
- lkpbc.PreviewLaporan(strDateFrom, strDateTo, strBlTh, intJenisLap);
- }
- protected void bindAllControl()
- {
- LunasKuitansiPBController lkpbc = new LunasKuitansiPBController();
- lkpbc.RvLapLunasKuitPB = viewerLapLunasKuitPB;
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- (some code in LunasKuitansiPBController.cs)
- public void PreviewLaporan(string strDateFrom, string strDateTo, string strBlTh, int intJenisLap)
- {
- Hashtable htData = new Hashtable();
- htData.Add("parFromDate", strDateFrom);
- htData.Add("parToDate", strDateTo);
- htData.Add("parBlTh", strBlTh);
- //throw new ApplicationException("strFromDate: " + strDateFrom + " strToDate: " + strDateTo);
- switch (intJenisLap)
- {
- #region catatan
- //this.cboReportTitle.Items.Add(new ListItem("Detil Pelunasan Kuitansi PB", "0"));
- //this.cboReportTitle.Items.Add(new ListItem("Rekap Pelunasan Kuitansi PB", "1"));
- //this.cboReportTitle.Items.Add(new ListItem("Ikhtisar Pelunasan BP dan UJL Per Tarif", "2"));
- //this.cboReportTitle.Items.Add(new ListItem("Daftar Pembayaran BP dan UJL", "3"));
- //this.cboReportTitle.Items.Add(new ListItem("Rekap Penerimaan BP dan UJL", "4"));
- #endregion
- case 0:
- DetilLunasKuitPB(htData);
- break;
- case 1:
- RekapLunasKuitPB(htData);
- break;
- case 2:
- IkhtisarBPUJL(htData);
- break;
- case 3:
- DaftarBPUJL(htData);
- break;
- case 4:
- RekapBPUJL(htData);
- break;
- }
- }
- private void DetilLunasKuitPB(Hashtable htData)
- {
- ReportDataSource rds0 = new ReportDataSource();
- rds0.Name = "Netway_CMS_F1_Data_Domain_Reports_LapLunasKuitPB";
- IList<LapLunasKuitPB> listmu = getLaporan(0, htData);
- rds0.Value = listmu;
- _rvLapLunasKuitPB.LocalReport.DataSources.Clear();
- _rvLapLunasKuitPB.LocalReport.DataSources.Add(rds0);
- _rvLapLunasKuitPB.LocalReport.ReportPath = "Netway.CMS.F1.Web\\Web\\CMC1141\\Reports\\RptPBLunasKuitansiDetil.rdlc";
- //_rvLapLunasKuitPB.LocalReport.ReportEmbeddedResource = "Netway.CMS.F1.Web.Web.CMC1141.Reports.RptPBLunasKuitansiDetil.rdlc";
- string strFromDate = htData["parFromDate"].ToString();
- string strToDate = htData["parToDate"].ToString();
- //throw new ApplicationException("strFromDate: " + strFromDate + " strToDate: " + strToDate);
- ReportParameter parFromDate = new ReportParameter("parFromDate", strFromDate);
- ReportParameter parToDate = new ReportParameter("parToDate", strToDate);
- this._rvLapLunasKuitPB.LocalReport.SetParameters(new ReportParameter[] { parFromDate, parToDate });
- _rvLapLunasKuitPB.LocalReport.Refresh();
- }
- private void RekapLunasKuitPB(Hashtable htData)
- {
- ReportDataSource rds = new ReportDataSource();
- rds.Name = "Netway_CMS_F1_Data_Domain_Reports_LapLunasKuitPB";
- IList<LapLunasKuitPB> list = getLaporan(1, htData);
- rds.Value = list;
- _rvLapLunasKuitPB.LocalReport.DataSources.Clear();
- _rvLapLunasKuitPB.LocalReport.DataSources.Add(rds);
- _rvLapLunasKuitPB.LocalReport.ReportPath = "Netway.CMS.F1.Web\\Web\\CMC1141\\Reports\\RptPBLunasKuitansiRekap.rdlc";
- //_rvLapLunasKuitPB.LocalReport.ReportEmbeddedResource = "Netway.CMS.F1.Web.Web.CMC1141.Reports.RptPBLunasKuitansiRekap.rdlc";
- string strFromDate = htData["parFromDate"].ToString();
- string strToDate = htData["parToDate"].ToString();
- ReportParameter parFromDate = new ReportParameter("parFromDate", strFromDate);
- ReportParameter parToDate = new ReportParameter("parToDate", strToDate);
- this._rvLapLunasKuitPB.LocalReport.SetParameters(new ReportParameter[] { parFromDate, parToDate });
- _rvLapLunasKuitPB.LocalReport.Refresh();
- }
- private IList<LapLunasKuitPB> getLaporan(int intJenisLap, Hashtable htData)
- {
- LunasKuitansiPBService lkpbs = new LunasKuitansiPBService();
- switch (intJenisLap)
- {
- case 0:
- return lkpbs.LapDetilLunasKuitPB(htData);
- //break;
- case 1:
- return lkpbs.LapRekapLunasKuitPB(htData);
- //break;
- case 2:
- return lkpbs.LapIkhtisarBPUJLPB(htData);
- //break;
- case 3:
- return lkpbs.LapDaftarBPUJLPB(htData);
- //break;
- case 4:
- return lkpbs.LapRekapBPUJLPB(htData);
- //break;
- default:
- return lkpbs.LapDetilLunasKuitPB(htData);
- //break;
- }
- }
Expand|Select|Wrap|Line Numbers
- (some code in LunasKuitansiPBService.cs)
- public IList<LapLunasKuitPB> LapDetilLunasKuitPB(Hashtable htData)
- {
- return Mapper.Instance().QueryForList<LapLunasKuitPB>("CMC1141.prevPBLunasDetil", htData);
- }
- public IList<LapLunasKuitPB> LapRekapLunasKuitPB(Hashtable htData)
- {
- return Mapper.Instance().QueryForList<LapLunasKuitPB>("CMC1141.prevPBLunasRekap", htData);
- }
Regards,
Novan Ananda