This is a migrated thread and some comments may be shown as answers.

Set Datasource Property for Graph at Runtime

1 Answer 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Steve asked on 29 Jul 2013, 06:39 PM
Hi All - 
I have a simple pie chart on a report that uses same datasource as the report. I can easily change the report datasource at runtime and all is well, but for some reason the chart throws the following (see attached). It works fine in preview in design mode, and all other reports I have bound with this method at runtime work perfectl. It is just adding the graph object I get this error. I have tried adding as subreport and just adding graph to report same issue -- it is loaded in the report footer. Here is the code I use to databind the report:

(NOTE: I am using a custom class and methods for getting data tables etc.. instantiated previously as db.)

                  Dim tbl As DataTable
                    tbl = db.GetDataTable("SELECT * FROM rpt_WholeProgram_Summary WHERE ProgramID = " & nProgramID)

                    Dim report1 As New BMETReports.WholeProgramSummary
                    report1.DataSource = tbl
                    '--------------- set Parameters -----------
                    'Get the Owner Name
                    Dim sOwnerName As String = db.GetSingleValue("SELECT IsNull(OwnerName,'owner name here') FROM Programs WHERE ProgramID = " & nProgramID)
                    report1.ReportParameters.Item("OwnerName").Value = sOwnerName
                    Dim sSubtitle As String = txtSubTitle.Text
                    Dim sProgramName As String = txtProgramName.Text
                    Dim sDraft As String = " "
                    If chkMarkDraft.Checked Then
                        sDraft = "DRAFT"
                    End If
                    report1.ReportParameters.Item("ProgramName").Value = sProgramName
                    report1.ReportParameters.Item("SubTitle").Value = sSubtitle
                    report1.ReportParameters.Item("Draft").Value = sDraft
                    Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
                    instanceReportSource.ReportDocument = report1
                    ReportViewer1.ReportSource = instanceReportSource

1 Answer, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 30 Jul 2013, 04:02 PM
Tech support gave me fix: -- note: the graph name is Graph2 in my report.

Dim graph = TryCast(report1.Items.Find("Graph2"True)(0), Graph)
graph.DataSource = tbl

General Discussions
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Share this question