Link to home
Start Free TrialLog in
Avatar of jasonwisdom
jasonwisdom

asked on

How do I display a Byte[] array as part of an ASP.NET webpage? (SQL Reporting Services)

Hi there.

I am looking to include the contents of a Byte[] array into an ASP.NET webpage I am using.  I am generating this Byte[] array using SQL Server 2000 Reporting Services, although you do not need to be familiar with this technology to help me out.  My goal is to display this Byte[] array in a fixed place in harmony with the rest of my ASP.NET page controls.

Here is my backend code, written in C#:

      Byte[] report;
      localhost.ReportingService rs = new localhost.ReportingService();
      /* stuff */
      report = rs.Render(all those parameters);
      /* more stuff */
      Response.BinaryWrite(report);

The key line is "Reponse.BinaryWrite(report);".  The Report generation stuff works.  What I'm getting is a webpage loading displaying the Report at the top, followed by the header and the rest of the page.

What I'd like is for this report to display in a certain place...say within a panel control, for example.  How can I do this?

Thank you very much,
Jason
Avatar of raterus
raterus
Flag of United States of America image

You can display it within a literal control within a panel...

myLiteralControl.text = Convert.ToBase64String(report)
ASKER CERTIFIED SOLUTION
Avatar of jnhorst
jnhorst

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 jasonwisdom
jasonwisdom

ASKER

Thank you John, the <iframe /> idea worked.  It requires a second page, however as this expands I see needing MDI-like functionality, so this is a bonus.


raterus, using a literal control in a panel did not work.  SQL Reporting Services returns a binary object, and when I executed the line...
Literal1.Text = Convert.ToBase64String(report);
..., I saw in the control a string which looked like this:

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEgVHJhbnNpdGlvbmFsLy9FTiI+DQo8aHRtbD4NCjxoZWFkPg0KPHRpdGxlPg0KUmVwb3J0MQ0KPC90aXRsZT4NCjxNRVRBIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjxNRVRBIGh0dHAtZXF1aXY9IkNvbnRlbnQtU3R5bGUtVHlwZSIgY29udGVudD0idGV4dC9jc3MiPg0KPE1FVEEgaHR0cC1lcXVpdj0iQ29udGVudC1TY3JpcHQtVHlwZSIgY29udGVudD0idGV4dC9qYXZhc2NyaXB0Ij4NCjxNRVRBIEhUVFAtRVFVSVY9IkxvY2F0aW9uIiBDT05URU5UPSJodHRwOi8vbG9jYWxob3N0L1JlcG9ydFNlcnZlcj8lMmZSZXBvcnRQcm9qZWN0MSUyZlJlcG9ydDEiPjxNRVRBIEhUVFAtRVFVSVY9IlVyaSIgQ09OVEVOVD0iaHR0cDovL2xvY2FsaG9zdC9SZXBvcnRTZXJ2ZXI

Thank you for your time, though.  I also began to try using a MemoryStream object, but found the iframe idea before I carried that to completion.

Jason
Apologies for going haywire with the width.......is there any way I can edit my own message?