急,关于C#水晶报表的问题
如何将水晶报表的SetDataSource()绑定自定义的DataTable,我的DataTable不来自任何数据库数据,是在程序运行当中根据用户输入生成的,请高手指教
急急急~
[解决办法]
DataSet myDataSet= new DataSet();
DataTable table = new System.Data.DataTable();
table.TableName = "Mytable";
table.Columns.Add(new System.Data.DataColumn("field1"));
table.Columns.Add(new System.Data.DataColumn("field2"));
...//添加数据
myDataSet.tables.add(table);
_ReportDoc.Load(this.m_strRptFileName,CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy);
_ReportDoc.SetDataSource(myDataSet);
注意:你的报表做的时候用推模式,而且名称(表名,字段名)要与你新建的table一样
[解决办法]
捕获输入,生成DataTable就是了
[解决办法]
ReportDocument reportDemo = new ReportDocument();
reportDemo.Load(Server.MapPath("表名.rpt"););
DataTable dt = ......... \\根入的值取得表的源 DataTable
reportDemo.SetDataSource(dt);
CrystalReportViewer1.ReportSource = reportDemo;
this.CrystalReportViewer1.DataBind();
主可以自己先建一XSD,里面包含你要用的所有的位名,
在表的候,只要把的位名拉倒 .rpt 面,CrystalReport就自
你呈