Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to print an SSRS Report in PDF Format from my asp.net page

How to print an SSRS Report in PDF Format from my asp.net page

Scheduled Pinned Locked Moved Database
csharpcssasp-netsql-servertutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vinay Meka
    wrote on last edited by
    #1

    Hi guys., I had an grid view where i had placed an link button to print an report.In this button click event i need to call the SSRS report and need to get the output as pdf file. I had used this below code,the code is running fine,but i'm unable to see the prompt to open/save pdf file.Plz reply ASAP.

    protected void btnAuthenticateAndPrint_Click(object sender, EventArgs args)
    {
    try
    {

            //Getting Values from grid
            LinkButton lb = (LinkButton)sender;
            GridViewRow row = (GridViewRow)lb.NamingContainer;
            Label lbOrderID = row.FindControl("lbOrderID") as Label;
            int OrderId = Convert.ToInt32(lbOrderID.Text);
            da = new SqlDataAdapter("Get\_PODetails", con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.SelectCommand.Parameters.AddWithValue("@MPDI\_ID", OrderId);
            ds = new DataSet();
            da.Fill(ds, "PO");
            if (ds.Tables\["PO"\].Rows.Count > 0)
            {
                lblPOId.Text=ds.Tables\["PO"\].Rows\[0\]\["MPDI\_ID"\].ToString();
                lblVendid.Text = ds.Tables\["PO"\].Rows\[0\]\["MVDI\_ID"\].ToString();
                lblBranch.Text = ds.Tables\["PO"\].Rows\[0\]\["MBRI\_ID"\].ToString();
                lblDate.Text = Convert.ToDateTime(ds.Tables\["PO"\].Rows\[0\]\["MPDI\_Date"\]).ToString("dd-MM-yyyy");
            }
    
            //SSRS Report Print
            rs = new RSWebService.ReportingService2005();
            rsExec = new REWebService.ReportExecutionService();
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rs.Url = "http://localhost/ReportServer/ReportService2005.asmx";
            rsExec.Url = "http://localhost/ReportServer/ReportExecution2005.asmx";
            byte\[\] Sendresults = null;
            byte\[\] bytes = null;
            string historyID = null;
            string deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
            string format = "PDF";
            string encoding = null;
            string mimeType = null;
            string extension = null;
            REWebService.Warning\[\] warnings = null;
            string\[\] streamIDs = null;
            string \_reportName = @"/FIMO GOF Assets Reports/PURCHASE ORDER";
            REWebService.ExecutionInfo ei = rsExec.LoadReport(\_reportName, historyID);
            REWebService
    
    L 1 Reply Last reply
    0
    • V Vinay Meka

      Hi guys., I had an grid view where i had placed an link button to print an report.In this button click event i need to call the SSRS report and need to get the output as pdf file. I had used this below code,the code is running fine,but i'm unable to see the prompt to open/save pdf file.Plz reply ASAP.

      protected void btnAuthenticateAndPrint_Click(object sender, EventArgs args)
      {
      try
      {

              //Getting Values from grid
              LinkButton lb = (LinkButton)sender;
              GridViewRow row = (GridViewRow)lb.NamingContainer;
              Label lbOrderID = row.FindControl("lbOrderID") as Label;
              int OrderId = Convert.ToInt32(lbOrderID.Text);
              da = new SqlDataAdapter("Get\_PODetails", con);
              da.SelectCommand.CommandType = CommandType.StoredProcedure;
              da.SelectCommand.Parameters.AddWithValue("@MPDI\_ID", OrderId);
              ds = new DataSet();
              da.Fill(ds, "PO");
              if (ds.Tables\["PO"\].Rows.Count > 0)
              {
                  lblPOId.Text=ds.Tables\["PO"\].Rows\[0\]\["MPDI\_ID"\].ToString();
                  lblVendid.Text = ds.Tables\["PO"\].Rows\[0\]\["MVDI\_ID"\].ToString();
                  lblBranch.Text = ds.Tables\["PO"\].Rows\[0\]\["MBRI\_ID"\].ToString();
                  lblDate.Text = Convert.ToDateTime(ds.Tables\["PO"\].Rows\[0\]\["MPDI\_Date"\]).ToString("dd-MM-yyyy");
              }
      
              //SSRS Report Print
              rs = new RSWebService.ReportingService2005();
              rsExec = new REWebService.ReportExecutionService();
              rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
              rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
              rs.Url = "http://localhost/ReportServer/ReportService2005.asmx";
              rsExec.Url = "http://localhost/ReportServer/ReportExecution2005.asmx";
              byte\[\] Sendresults = null;
              byte\[\] bytes = null;
              string historyID = null;
              string deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
              string format = "PDF";
              string encoding = null;
              string mimeType = null;
              string extension = null;
              REWebService.Warning\[\] warnings = null;
              string\[\] streamIDs = null;
              string \_reportName = @"/FIMO GOF Assets Reports/PURCHASE ORDER";
              REWebService.ExecutionInfo ei = rsExec.LoadReport(\_reportName, historyID);
              REWebService
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Don't crosspost, choose one forum and stick to it.

      One of these days I'm going to think of a really clever signature.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups