I am new to C# and ASP .NET programming. I am making a crystal report in .net. I setup Dataset
and DataTable
. For report sources.
I am getting data from a linq query. and after that I am populating them in a instance of Dataset
. I use debugger and it shows that I have data from the query. But my crystal reeport just shows the column heading not the column data.
Here is my code:
private void ViewReport()
{
DataSet1 Dataset = new DataSet1();
DataTable rptTable = Dataset.Tables["Emp_info"];
DataTable rptTab = Dataset.Tables["Attendance_table"];
Ind_attendance_rpt rptAtd = new Ind_attendance_rpt();
DataRow dataRow1; // declaring Row of dataset
DataRow dataRow2;
//IndividualAttendance rptAtt = new IndividualAttendance();
var rport = from att in db.Attendance_tables
join emp in db.Emp_infos on att.Login_id equals emp.ID
orderby att.Id
select new
{
att.Id,
emp.Emp_name,
emp.ID,
emp.Designation,
emp.Dept,
att.Entry_time,
att.Exit_time,
att.Status,
att.Date
};
Dataset.Tables["Emp_info"].Clear();
Dataset.Tables["Attendance_table"].Clear();
foreach (var rt in rport)
{
dataRow1 = rptTable.NewRow();
dataRow2 = rptTab.NewRow();
dataRow2["Id"] = rt.Id;
dataRow1["Emp_name"] = rt.Emp_name;
dataRow1["Designation"] = rt.Designation;
dataRow1["Dept"] = rt.Dept;
dataRow2["Entry_time"] = rt.Entry_time;
dataRow2["Exit_time"] = rt.Exit_time;
dataRow2["Status"] = rt.Status;
dataRow2["Date"] = rt.Date;
dataRow2["Login_id"] = rt.ID;
Dataset.Tables["Emp_info"].Rows.Add(dataRow1);
Dataset.Tables["Attendance_table"].Rows.Add(dataRow2);
}
rptAtd.SetDataSource(Dataset);
CrystalReportViewer1.ReportSource = rptAtd;
}
Can anyone tell me the reason?
Here is the result I am getting right now:
Debug Image: