Value does not fall within the expected range exception while using ReportDataSource

Here is my code which produce “Value does not fall within the expected range” exception. 

ReportDataSource objReportDataSource
              = new ReportDataSource(“CategoryProduct”);
objReportDataSource.Name = “NewDataSet_CategoryProducts”;
// dsDataSet is DataSet object
objReportDataSource.Value = dsData;

            After doing some try and error method I found that this exception is due to objReportDataSource.Value = dsData.

You need to assign a DataTable to Value property instead of DataSet. Below is the code that is working fine.

ReportDataSource objReportDataSource
              = new ReportDataSource(“CategoryProduct”);
objReportDataSource.Name = “NewDataSet_CategoryProducts”;
// dsDataSet is DataSet object
objReportDataSource.Value = dsData.Tables[0];

Happy Programming !!!

 

 

Ref: http://chiragrdarji.wordpress.com/2007/09/01/value-does-not-fall-within-the-expected-range-exception-while-using-reportdatasource-2/

posted @ 2008-05-26 06:22  Vincent Yang  阅读(2695)  评论(1编辑  收藏  举报