locked
report with my own types RRS feed

  • Question

  • User-1669453032 posted

    HI, i am developing an application using ASP.NET MVC4 .

    i want to develop a report (RDLC) using my own classes or objects rather dataset or database approaches.

    this is not related to SQL Server nor mysql. i want to use my own types as a datasource.

    kindly guide. thanks

    Thursday, December 12, 2013 1:44 AM

Answers

  • User513209653 posted

     Hi,

            Yes, it is possible to do it. You can use simple classses and objects to create RDLC reports.

            You can also simply display the value of variables to your RDLC report without using DataSet

            or DataTable. You can do it by passing the values as parameters. Though it is not convenient but

            if you really want to do it , it can be done.

            Here is a small example:

            I have declared three variables in my Page_Init event and I will pass the values of these

            variables to the Report as Parameters.

        

       public void Page_Init(object sender, EventArgs e)
    
            {
    
                int id = 1;
    
                string name = "SAM";
    
                string year = "2013";
    
     
    
                Microsoft.Reporting.WebForms.ReportParameter[] param = new Microsoft.Reporting.WebForms.ReportParameter[3];
    
                param[0] = new Microsoft.Reporting.WebForms.ReportParameter("ID", id.ToString());
    
                param[1] = new Microsoft.Reporting.WebForms.ReportParameter("Name", name);
    
                param[2] = new Microsoft.Reporting.WebForms.ReportParameter("Year", year);
    
                ReportViewer1.LocalReport.SetParameters(param);
    
            }
    

           Now, add a RDLC report to your project and then add a ReportViewer control.

           Go to the source and set ReportPath value of the LocalReport.

           ReportPath="[name of the rdlc report].rdlc"

            Finally ,edit the RDLC report to create three Parameters

            Param

            Drag and Drop the Parameters from Report Data window to the Report.

            It works fine. You can get the idea and add mode customization for your code.

            Hope it works!

            Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 19, 2013 4:16 AM