i am trying to create a parameterized report using two data table in one dataset this is because in the first datatable i am getting all the records and displaying it on the page load event but when the user enters a from date and to date parameter and click filter i would like for the report to change to the other datatable that takes in the parameters.
What appreas at page load:
i accomplished the above with this code
if (Page.IsPostBack == false)
{
NetWeightIolaDataSet.Net_Weight_Tracking1DataTable table = new NetWeightIolaDataSet.Net_Weight_Tracking1DataTable();
NetWeightIolaDataSetTableAdapters.Net_Weight_Tracking1TableAdapter adpt =
new NetWeightIolaDataSetTableAdapters.Net_Weight_Tracking1TableAdapter();
adpt.Fill(table);
ReportDataSource rds = new ReportDataSource("NetWeightIolaDataSet_Net_Weight_Tracking1", table);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
ReportViewer1.Visible = true;
}
i can get the parameters to work on the report if i use this code and add parameters in the report :
//ReportParameter param = new ReportParameter("fromdate", fromdate.Text);
//this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { param });
//ReportParameter paramm = new ReportParameter("todate", todate.Text);
//this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { paramm });
but i dont want to do it like this instead i would like to pass the parameters to the report via datatable in a dataset and then assign that has a source to the report but when i did that i get this error:
A data source instance has not been supplied for the data source 'NetWeightIolaDataSet_Net_Weight_Tracking1'.
my dataset:
so on page load display all data using datatable with no parameters but when a date range is provided and when the filter button is clicked use the other datatable as the report source:
this is the code for passing the value from the textbox and filling in the datatable with the parameter:
NetWeightIolaDataSet.Net_Weight_TrackingDataTable table = new NetWeightIolaDataSet.Net_Weight_TrackingDataTable();
NetWeightIolaDataSetTableAdapters.Net_Weight_TrackingTableAdapter adpt = new NetWeightIolaDataSetTableAdapters.Net_Weight_TrackingTableAdapter();
adpt.Fill(table, DateTime.Parse(fromdate.Text), DateTime.Parse(todate.Text));
ReportDataSource rds = new ReportDataSource("NetWeightIolaDataSet_Net_Weight_Tracking", table);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
ReportViewer1.Visible = true;


So i ended up creating a stored procedure and said that if the parameters are null then give me all records if they have value run the other code and all created a button and called it AllData this will return all records to the user at any point in time.