A data source instance has not been supplied for the data source "Test_ChartData"
I created a ReportViewer from the toolbox. I then proceeded to create a form that contains a single bar chart. At this point, I created a very simple class:
classChartData
{
publicint Param1
{
get
{
return 1;
}
}
}I then added this as a data source by selecting "Object." From the Data Sources Window, I dragged Param1 into the chart's "drop data fields here" region. Now I try to run my project and I get:
A data source instance has not been supplied for the data source "Test_ChartData"
How do I assign a data source instance? Is there anything else I will need to do to get this working?
Thanks in advance!
[1063 byte] By [
DMeglio] at [2008-2-15]
You can supply a data source instance like this:
reportViewer.LocalReport.DataSources.Add(
new ReportDataSource("Test_ChartData", mydata));
Note that if you select the report into ReportViewer using the smart tags panel then a bindingsource object is created for you. In this case you can simply set the DataSource property of the BindingSource.
I have attempted this already, using the second method you mentioned. I assigned a report using the smart tag. My form load event is:
private void Form1_Load(object sender, EventArgs e)
{
ChartData cd = new ChartData();
ChartDataBindingSource.DataSource = cd;
this.reportViewer1.RefreshReport();
}I also tried using the other method, yielding a form load event of:
private void Form1_Load(object sender, EventArgs e)
{
ChartData cd = new ChartData();
reportViewer1.LocalReport.DataSources.Add(
new ReportDataSource("Test_ChartData", cd));
this.reportViewer1.RefreshReport();
}
This resulted in:
************** Exception Text **************
System.ArgumentException: Value does not fall within the expected range.
at Microsoft.Reporting.WinForms.ReportDataSource.set_Value(Object value)
at Microsoft.Reporting.WinForms.ReportDataSource..ctor(String name, Object dataSourceValue)
at Test.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\dominick.meglio\my documents\visual studio 2005\Projects\Test\Test\Form1.cs:line 24
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Fantastic! Thank you. Just to know for the future, since you said "in beta 2", does this mean that in a future version I will not need to supply a collection?
Thanks again.