I stepped through the report event and noted that the NeedDataSource fires whenever I press preview from the Report viewer. I do notice however, that the NeedDataSource event fires again when I do an export from the report viewer. This event is where I set the report.DataSource, this also means that this is where I run the database queries.
I would have thought that since the report.DataSource has already been set/cached during the "preview" action (through the NeedDataSource), the "export to excel" action will not cause the NeedDataSource event to fire again. This is a winforms application by the way so asp.net statelessness is not an issue.
You see, I have a fairly large monthly data set and it takes twice the time to preview the report and export the report because of this NeedDataSource event.
How is the NeedDataSource event triggered? What sets the report.Datasource to nothing?
An example of the NeedDataSource event:
Private Sub MonthlyAccepted_AS_MasterReport_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.NeedDataSource
Dim subGroupName As ISOSettlementProvisionSubGroupName = EnumUtility(Of ISOSettlementProvisionSubGroupName).Parse(Me.ReportParameters(SETTLEMENT_TYPE).Value)
Dim dayofMonth As Date = Date.Parse(Me.ReportParameters(MONTH).Value & " 1, " & Me.ReportParameters(YEAR).Value)
me.DataSource = BusinessObjects.MonthlyAcceptedASInfo.GetData(dayofMonth, subGroupName)
End Sub
Thanks.
<
sessionState timeout="60" />
Any ideas?
| Imports System |
| Imports Telerik.Reporting.Chart |
| Public Partial Class Report1 |
| Inherits Report |
| Public Sub New() |
| """ <summary> |
| """ Required for telerik Reporting designer support |
| """ </summary> |
| InitializeComponent() |
| End Sub |
| Private Sub chart1_NeedDataSource(sender As Object, e As System.EventArgs) |
| " create a datasource |
| Dim sqlDataSource As New SqlDataSource() |
| sqlDataSource.ID = "myDataSource" |
| sqlDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString |
| sqlDataSource.SelectCommand = "SELECT CategoryName, SUM(ProductSales) AS TotalSales FROM [Product Sales for 1997] GROUP BY CategoryName" |
| Dim procChart As Telerik.Reporting.Processing.Chart = DirectCast(sender, Telerik.Reporting.Processing.Chart) |
| procChart.DataSource = "myDataSource" |
| " Set the column for data and data labels: |
| " Each bar will show "TotalSales", each label along |
| " X-axis will show "CategoryName. |
| chart1.Series(0).DataYColumn = "TotalSales' |
| chart1.PlotArea.XAxis.DataLabelsColumn = 'CategoryName' |
| " assign appearance related properties |
| chart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 300 |
| chart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.BlueViolet |
| chart1.PlotArea.Appearance.Dimensions.Margins.Bottom = Telerik.Reporting.Charting.Styles.Unit.Percentage(30) |
| End Sub |
| End Sub |
| End Class |