我想制作一份水晶报告,但问题来自于我 setdatasource(dataset) 我想以编程方式制作水晶报告。
当我添加数据源.it时会出现以下错误
Cannot assign to 'SetDataSource' because it is a 'method group'
请指导我如何制作水晶报告
protected void Page_Load(object sender, EventArgs e)
{
var context = new MedicalPointDBEntities();
List<Customer> clist = new List<Customer>();
clist = context.Customer.Select(i => i).ToList();
DataTable customerTable = new DataTable();
customerTable.Columns.Add("Cusomer Name");
customerTable.Columns.Add("Customer CNIC");
customerTable.Columns.Add("Customer Location");
foreach (Customer x in clist)
{
DataRow row = customerTable.NewRow();
row[0] = x.CustomerName;
row[1] = x.CustomerCNIC;
row[2] = x.CustomerLocation;
customerTable.Rows.Add(row);
}
DataSet ds = new DataSet();
ds.Tables.Add(customerTable);
ReportDocument crys = new ReportDocument();
crys.Load(Server.MapPath("CRCustomer.rpt"));
crys.SetDataSource = ds;
CrystalReportViewer1.ReportSource = crys;
CrystalReportViewer1.DataBind();
CrystalReportViewer1.RefreshReport();
}
答案 0 :(得分:1)
ReportDocument.SetDataSource
是一个方法,而不是一个属性,所以你应该调用它,而不是赋值给它:
crys.SetDataSource(ds);