c# - Unable to dynamically update display report in Report Viewer Control -
i using following code change reports displayed in report viewer control on button click event.
private void reinitializeviewer(string tsreport) { reportdatasource reportdatasourcex = new reportdatasource(); this.purchasereprotviewer.reset(); this.purchasereprotviewer.localreport.reportembeddedresource = tsreport; if (tsreport.contains("rpt_purchaseinvoice.rdlc")) { this.purchasetableadapter.fill(this.gmsdataset.purchase); reportdatasourcex.name = "purchaseinvoicedataset"; reportdatasourcex.value = this.gmsdataset.tables["purchase"]; } else { reportdatasourcex.name = "dataset1"; // reportdatasourcex.value = me.mybindingsource1 } this.purchasereprotviewer.localreport.datasources.add(reportdatasourcex); //this.purchasetableadapter.fill(this.gmsdataset.purchase); this.purchasereprotviewer.refreshreport(); } private void cmd_purchaseinvoices_click(object sender, eventargs e) { reinitializeviewer("rpt_purchaseinvoice.rdlc"); }
but getting strange error in output.
i unable identify what's going wrong in above code. appreciated. in advance.
found answer myself.
following code worked me:
private void reinitializeviewer(string tsreport) { reportdatasource reportdatasourcex = new reportdatasource(); this.purchasereprotviewer.reset(); if (tsreport.contains("rpt_purchaseinvoice.rdlc")) { reportdatasourcex.name = "purchaseinvoicedataset"; reportdatasourcex.value = this.purchasebindingsource; this.purchasereprotviewer.localreport.datasources.add(reportdatasourcex); this.purchasereprotviewer.localreport.reportembeddedresource = tsreport; this.purchasereprotviewer.refreshreport(); } }
Comments
Post a Comment