c# - Activereports PageReport creation by using custom data -
i wanna create page report based on custom class , pagereport contains table inside.
say example have customer data class follow
class customerdata { string name; string id; string address; }
and create list<customerdata>
customerlist contains customer data. want assign data datasource pagereport. know in sectionreport can this. how assign list of information pagereport. me
ultimately expecting output below
---------------------------------------------- |name | id | address | ---------------------------------------------- |name1 | id1 | address1 | ---------------------------------------------- |name2 | id2 | address2 | ---------------------------------------------- |name3 | id3 | address3 | ----------------------------------------------
update
componentidinfo 1 of field
do, this:
this._rptpath = new fileinfo(@"..\..\pagereport1.rdlx"); this._definition = new pagereport(this._rptpath); this._definition.configurationprovider = new grapecity.activereports.configuration.defaultconfigurationprovider(); this._runtime = new pagedocument(this._definition); this._runtime.locatedatasource += this.runtime_locatedatasource; this.yourviewer.reportviewer.loaddocument(this._runtime);
and on runtime_locatedatasource
event, add following code:
private void runtime_locatedatasource(object sender, locatedatasourceeventargs args) { object data = null; string datasetname = args.datasetname; string datasourcename = args.datasourcename; if (stringsareequal("datasource1", datasourcename)) { if (stringsareequal("dataset1", datasetname)) { data = customerlistdatatable; } } args.data = data; } private static bool stringsareequal(string str1, string str2) { return string.compare(str1, str2, true, cultureinfo.invariantculture) == 0; }
please note have create datasource
named datasource1
, dataset
named dataset1
in page report. , match column names of dataset1
customer's
class public properties
.
to add datasource
, right click on outside of page report
(gray area) , select property
, datasource
in property
window.
how add datasource/dataset
- in report explorer, right-click data sources node , select add data source option.
- in report data source dialog appears, select general page , in name field, enter name datasource1.
- right click data source node , select add data set option.
- in dataset dialog appears, select general page , enter name of dataset dataset1. name appears child node data source icon in report explorer.
- go fields tab , enter dataset's fields (columns) there
please note if cannot find report explorer
, go visual studios
view
menu , go other windows
.
Comments
Post a Comment