
private
void chart1_NeedDataSource(object sender, EventArgs e)
{
Telerik.Reporting.Processing.
Chart chart = sender as Telerik.Reporting.Processing.Chart;
SqlConnection conn = new SqlConnection("Server=(local);Database=UMG;Integrated Security=SSPI;");
SqlCommand command = new SqlCommand("GetDiagnosisReport", conn);
command.CommandType =
CommandType.StoredProcedure;
command.Parameters.AddWithValue(
"@Country", this.ReportParameters["Country"].Value);
command.Parameters.AddWithValue(
"@FromDate", this.ReportParameters["FromDate"].Value);
command.Parameters.AddWithValue(
"@ToDate", this.ReportParameters["ToDate"].Value);
command.Parameters.AddWithValue(
"@Count", this.ReportParameters["Count"].Value);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
try
{
adapter.Fill(ds);
}
catch (Exception ex)
{
System.Diagnostics.
Debug.WriteLine(ex.Message);
}
DataView view = ds.Tables[0].DefaultView;
chart.DataSource = view;
}
but when I got chart without bound any value (there is no ,or empty series)
then I put parameters and press for preview I got this error
|
An error has occured while processing Chart 'chart1':
An Unexpected error has occurred. Please review the InnerException for more information how to resolve the problem. |
||
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| If Me.IsPostBack Then |
| If Me.RadDatePickerStartDate.SelectedDate.HasValue = True And Me.RadDatePickerEndDate.SelectedDate.HasValue = True Then |
| Dim newrpt As New rptSummary(CDate(Me.RadDatePickerStartDate.SelectedDate.Value), CDate(Me.RadDatePickerEndDate.SelectedDate.Value)) |
| Me.ReportViewer1.Report = newrpt |
|
Response.Write( CType(CType(Me.ReportViewer1.Report, rptSummary).DataSource, svcDailyStats.clsDailyStatistics).intTotalCalls)
|
| End If |
| End If |
| End Sub |
And here we see some code from my report
| Imports System.ComponentModel |
| Imports System.Drawing |
| Imports System.Windows.Forms |
| Imports Telerik.Reporting |
| Imports Telerik.Reporting.Drawing |
| Partial Public Class rptSummary |
| Inherits Telerik.Reporting.Report |
| Private objDailyStats As svcDailyStats.DailyStats |
| Private DailyStats As svcDailyStats.clsDailyStatistics |
| Public Sub New() |
| InitializeComponent() |
| objDailyStats = New svcDailyStats.DailyStats |
| DailyStats = objDailyStats.GetDailyStatsEmpty() |
| Me.DataSource = DailyStats |
| End Sub |
| Public Sub New(ByVal startDate As Date, ByVal enddate As Date) |
| InitializeComponent() |
| objDailyStats = New svcDailyStats.DailyStats |
| DailyStats = objDailyStats.GetDailyStats(startDate, enddate) |
| Me.DataSource = DailyStats |
| End Sub |
| End Class |
Now as an example lets assume I submit my page with the values of RadDatePickerStartDate = '01/03/2009' and RadDatePickerEndDate = '02/03/2009'
The report runs, the datasource is set with the newly created business object using these 2 dates as expected.
Now lets suppose I change those 2 dates and submit the page again, for some reason the report doesn't change. You'll see the response.write in the above code, intTotalCalls is a property of my business object that I am setting as a datasource for my report. This value will change and display on my page as expected for the response.write but it will not change in my visible report and always remains the same as the first time the report was run as do all other fields in the report.