hi all,
i have a reportviewer in acsx file(controll).
i try to attach dynamicly it datasource in this way:
Protected Sub cmdGetReport_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles cmdGetReport.Click ReportViewer1.Visible =True Dim ObjectDataSource1As ObjectDataSource =New ObjectDataSource ObjectDataSource1.TypeName ="ReportDataSetTableAdapters.Contel_Enercon_RptInvoiceByAccountTableAdapter" ObjectDataSource1.SelectParameters.Clear()If cboAccountList.SelectedValue > 0Then ObjectDataSource1.SelectMethod ="GetInvoiceByAccount" ObjectDataSource1.SelectParameters.Add("SiteID", cboSiteList.SelectedValue) ObjectDataSource1.SelectParameters.Add("InvoiceID", cboInvoiceList.SelectedValue) ObjectDataSource1.SelectParameters.Add("AccountID", cboAccountList.SelectedValue)Else ObjectDataSource1.SelectMethod ="GetAllInvoiceBySite" ObjectDataSource1.SelectParameters.Add("SiteID", cboSiteList.SelectedValue) ObjectDataSource1.SelectParameters.Add("InvoiceID", cboInvoiceList.SelectedValue)End If Dim rdsAs ReportDataSource =New ReportDataSource rds.DataSourceId ="ObjectDataSource1" rds.Name ="ReportDataSet_Contel_Enercon_RptInvoiceByAccount" ReportViewer1.LocalReport.DataSources.Add(rds) ReportViewer1.LocalReport.Refresh()End Sub
but when i try to open the report i get this error msg:
The DataSourceID of the ReportDataSource 'ReportDataSet_Contel_Enercon_RptInvoiceByAccount' of the ReportViewer 'ReportViewer1' must be the ID of a control of type IDataSource. A control with ID 'ObjectDataSource1' could not be found.
any idea?
Well I solved it.
Instead :
Dim rdsAs ReportDataSource =New ReportDataSource rds.DataSourceId ="ObjectDataSource1" rds.Name ="ReportDataSet_Contel_Enercon_RptInvoiceByAccount"
i wrote:Dim rdsAs ReportDataSource =New ReportDataSource("ReportDataSet_Contel_Enercon_RptInvoiceByAccount",ObjectDataSource1)
And it worked...
No comments:
Post a Comment