问题
I have a rdlc report I want to bind a list of my own custom class to as a data source.
I've used some code recommended on this site to build the DataTable
This works really well
//convert my list of Invoices to a DataTable
var dt = invoices.CopyToDataTable(dataTable, LoadOption.PreserveChanges);
//Setup a new DataSource
var rds = new ReportDataSource {Name = "ReportDataSet", Value = dt};
//Add that datasource to my ReportViewer
rvSampleInvoice.LocalReport.DataSources.Add(rds);
//Map my report path, etc
rvSampleInvoice.LocalReport.ReportPath = Server.MapPath("etc");
This all works fine, when I load my page, the report shows, but it only has one 2 pages. the first is the first entry in my invoices collection, and when I click next page, it's a blank page. I've added a gridview to the page, and bound the DataTable (dt) to it and it displays as a nice table with a row of headers and 20 rows of data.
I'm wondering if I've got something wrong on how to bind a RDLC to my List of Invoices
回答1:
This SO answer has has solved the issue. There's gotta be a better way of doing this, so if anyone knows a better way to have multiple pages for one result set, let me know
Update:
Ok, I'll explain what I've learnt now more about RDLCs for future archeologists. You can't just drag and drop data into a page, bind a list of items and expect it to duplicate the sample page you've made however many times there are items in your list. You need to drag a table into the report and tick the "page break" option in the SO solution I linked to. Then stretch the table across the page, add a bunch of rows and columns. The fill in the cells you want in your page. It takes a bunch of cell merging and stretching to get it to look the way I want, so if there's a better way, someone please make a post.
来源:https://stackoverflow.com/questions/15064787/rdlc-report-not-paging-with-dynamically-bound-datasource