[英]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, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Unhandled Error:" + ex.Message);
}
}
問題:無法在Reportviewer中綁定報表。 我在“ dtnew”中獲得了記錄,但是在我的應用程序中看不到該報告
報告中出現錯誤“尚未為數據源'dsInOutReport_InOut'提供數據源實例“
添加:
reportViewer1.LocalReport.DataSources.clear();
在這之前:
reportViewer1.LocalReport.DataSources.Add(rptds);
這將起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.