Problem with rdlc Report in asp.net
private void btnGenerate_Click(object sender, EventArgs e)
{
try
{
if (Convert.ToDateTime(dateTimeTo.Text).Date >= Convert.ToDateTime(dateTimeFrom.Text).Date)
{
DateTime today = DateTime.Today.Date;
reportViewer1.RefreshReport();
reportViewer1.LocalReport.Refresh();
DataTable dtnew = new DataTable();
string EmpId = null;
if (ddlEmployee.SelectedIndex > 0)
{
EmpId = ddlEmployee.SelectedValue.ToString();
}
reportViewer1.LocalReport.DataSources.Clear();
dtnew = new dbInOutTimeDatasetTableAdapters.InOutTableAdapter().GetData(Convert.ToDateTime(dateTimeTo.Text), Convert.ToDateTime(dateTimeFrom.Text),new Guid(EmpId));
// dtnew = new dsReportTableAdapters.ReportTableAdapter().GetData(Convert.ToDateTime(dateTimeFrom.Text), Convert.ToDateTime(dateTimeTo.Text), EmpId, DeptId);
reportViewer1.Visible = true;
ReportDataSource rptds = new ReportDataSource("dbInOutTimeDataset_ReportInOut", dtnew);
reportViewer1.LocalReport.DataSources.Add(rptds);
reportViewer1.LocalReport.Refresh();
reportViewer1.RefreshReport();
reportViewer1.Visible = true;
}
else
{
MessageBox.Show("To date must be greater or equal to From date.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (InvalidOperationException exI)
{
MessageBox.Show("There is no any Employee Absent.", "Information", MessageBoxButtons.OK, Mes开发者_StackOverflow中文版sageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Unhandled Error:" + ex.Message);
}
}
Problem: Cant bind the report in Reportviewer. I get the record in "dtnew", but cnt see the report in my application
Get Error in report " A data source instance has not been supplied for the data source 'dsInOutReport_InOut'"
add this:
reportViewer1.LocalReport.DataSources.clear();
before this:
reportViewer1.LocalReport.DataSources.Add(rptds);
this will work.
精彩评论