2

I want to generate report in MVC4 application. I am trying by Microsoft RDLC report but i don't want to create a data-set. i am creating my own list of data and that list i want to show in the report. I am creating list after fetching data from various table. I had gone through various links but all links given me the steps to create report with data-set.

I tried to get some from Google, but do not found any reliable solution for same.. Any help will be highly appreciated.

AmitCharkha
  • 209
  • 4
  • 18
  • Check this [SO post](http://stackoverflow.com/questions/6144513/how-can-i-use-a-reportviewer-control-in-an-asp-net-mvc-3-razor-view/7176529#7176529), and [google](https://www.google.co.uk/#safe=on&q=how+to+use+rdlc+report+in+mvc+4) in this case might be helpful too. As for how to use your custom objects, refer to [MSDN](http://msdn.microsoft.com/en-us/library/ms252094.aspx). – Michael Oct 09 '14 at 13:36

1 Answers1

0

We are using

public ReportDataSourceCollection DataSources { get; }

from Microsoft.Reporting.WebForms and then add a custom datasource to our report engine with

myReportEngine.DataSources.Add(new ReportDataSource("MyData", data));

where data can be DataTable, IDataSource or an IEnumerable as you need it.

In the report definition (rdlc) we use the following dummy data set that maps to our data

<DataSources>
  <DataSource Name="MyDataSource">
    <ConnectionProperties>
      <DataProvider>SQL</DataProvider>
      <ConnectString>data source=localhost;initial catalog=MyDataCollection</ConnectString>
      <IntegratedSecurity>true</IntegratedSecurity>
    </ConnectionProperties>
  </DataSource>
</DataSources>
<DataSets>
  <DataSet Name="MyData">
    <Fields>
      <Field Name="MyField1">
        <DataField>MyField1</DataField>
    </Field>
    ...
   </Fields>
  </DataSet>
</DataSets>

Comment: MyDataCollection and MyDataSource must not be set in code.

StefanG
  • 1,234
  • 2
  • 22
  • 46