111*_*110 10 c# asp.net dataset crystal-reports
我不想从代码创建DataSet并将其设置为crystal report的数据源.
如果我不需要,我不想在VS中创建DataSet xsd文件.只是纯粹的代码.
DataSet ds = new DataSet();
DataTable tbl = new DataTable();
DataColumn cln = new DataColumn();
// I fill row, columns, table and add it to ds object
...
然后,当我需要报告时,我使用:
myReport.SetDataSource(ds);
这里的问题是我不知道如何绑定这个报告?如何添加字段?
我有一个文本和二进制数据(图像).
小智 15
只有出路.正如罗萨多所建议的那样.一点点解释1. CReate一个RPT文件.2.使用所需列创建XSD.3.拖放rpt上的列.根据需要格式化.4.现在创建连接,使用适配器填充该数据集.5.填写u数据集将自动填充报告列.
以下是我的一个项目的示例代码.
Invoice invoice = new Invoice(); // instance of my rpt file
var ds = new DsBilling();  // DsBilling is mine XSD
var table2 = ds.Vendor;
var adapter2 = new VendorTableAdapter();
adapter2.Fill(table2);                   
var table = ds.Bill;
var adapter = new BillTableAdapter();
string name = cboCustReport.Text;
int month = int.Parse(cboRptFromMonth.SelectedItem.ToString());
int year = int.Parse(cboReportFromYear.SelectedItem.ToString());
adapter.Fill(table, name,month,year);
ds.AcceptChanges();
invoice.SetDataSource(ds);
crystalReportViewer1.ReportSource = invoice;
crystalReportViewer1.RefreshReport();