One way to create report in the SharePoint with source as list or external data sources is using rdlc files.
To create report using rdlc files the first thing we need is a rdlc template of the report. Using visual studio we can create a rdlc file referring to a particular data source.
To create a rdlc based report do the following steps.
- Open the vs create a visual web part project and add a report viewer to the ascx page.
- Now the next step is to create an rdlc file , for this add a new rdlc file from the Add > New Item > Reporting.
- Drop a table in the rdlc file this will open a data source selection wizard.
- Create a data Set and in the data source select sharepoint (in case the data source is from sharepoint)
- Once this reference is added reselect the Object (where you selected the SharePoint option )in the selection and select particular lineitem template required, this can be a line item template of an existing list , or a new list we create to get the report template (once the rdlc file is created we can remove this list also).
Now map the columns in them as required.
So the design of the template is done.
- Keep this rdlc file in the app root path.
- Now the next steps is to bind the data .
//populate the data in a data table either using caml query or linq (using caml is good for the performance)
DataTable items = dt;
//use server.mappath to direct to the rdlc file.
this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/po.rdlc");
// assign the datatable , note that the name parameter (first) will be same as that in the rdlc file(and should be unique for each report to avoid data mapping conflict.)
ReportDataSource rds = new ReportDataSource("PoData", items);
// and add the report data source to the reportviewer control as below.
- Deploy the visual webpart to the desired webpart zone.
In case you need parameters to the report design it at the visual webpart so the query will filter out the data.
Happy reporting without sharepoint ssrs integration.