Link to home
Start Free TrialLog in
Avatar of DB_Fury
DB_Fury

asked on

create C# method from code

i want to make the following code into its own method so i can use it multiple times.  can someone show me how to do that?
ReportViewer rview = new ReportViewer();
        rview.ServerReport.ReportServerUrl = new Uri(WebConfigurationManager.AppSettings["ReportServer"]);

        List<ReportParameter> paramList = new List<ReportParameter>();

        paramList.Add(new ReportParameter("FacilityID", Globals.FacilityID.ToString()));

        rview.ServerReport.ReportServerCredentials = new ReportCredentials("xxxx", "xxxx", "xxxx");
        rview.ServerReport.ReportPath = "/BoardAssessment/AssessmentReport";
        rview.ServerReport.SetParameters(paramList);
        string mimeType, encoding, extension, deviceInfo;
        deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>";
        string[] streamids;

        Warning[] warnings;
        byte[] bytes = rview.ServerReport.Render("Excel", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
        Response.ContentType = "application/Excel";
        Response.AddHeader("Content-disposition", "attachment;filename=BoardAssessment.xls");

        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.OutputStream.Flush();
        Response.OutputStream.Close();
        Response.Flush();
        Response.Close();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of w00te
w00te
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DB_Fury
DB_Fury

ASKER

thanks i figured it out