12 Answers, 1 is accepted
0
Hi rh,
You have to attach to the DetailSection's ItemDataBound event. Inside it, you can obtain a reference to the current row through the DataItem property and set the appropriate image. We have prepared a little sample that demonstrates how to do that. Please take a look at it and if you have further questions, feel free to contact us again. Here is an excerpt of its source code:
Regards,
Rossen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You have to attach to the DetailSection's ItemDataBound event. Inside it, you can obtain a reference to the current row through the DataItem property and set the appropriate image. We have prepared a little sample that demonstrates how to do that. Please take a look at it and if you have further questions, feel free to contact us again. Here is an excerpt of its source code:
public partial class DynamicPictureReport : Report | |
{ | |
public DynamicPictureReport() | |
{ | |
InitializeComponent(); | |
DataTable dummyData = new DataTable(); | |
dummyData.Columns.Add("ID"); | |
for(int i = 0; i < 3; i++) | |
{ | |
dummyData.Rows.Add(i); | |
} | |
this.DataSource = dummyData; | |
} | |
private void detail_ItemDataBound(object sender, System.EventArgs e) | |
{ | |
Telerik.Reporting.Processing.DetailSection procDetail = sender as Telerik.Reporting.Processing.DetailSection; | |
Telerik.Reporting.Processing.PictureBox procPictureBox = procDetail.Items["pictureBox"] as Telerik.Reporting.Processing.PictureBox; | |
DataRowView row = procDetail.DataItem as DataRowView; | |
string currentId = row["ID"] as string; | |
Bitmap image = new Bitmap(100, 100); | |
Graphics dummy = Graphics.FromImage(image); | |
Font font = new Font("Arial", 18); | |
dummy.DrawString("I am " + currentId, font, Brushes.Red, new RectangleF(0, 0, 100, 100)); | |
procPictureBox.ImageData = image; | |
} | |
} | |
Regards,
Rossen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Michael Helm
Top achievements
Rank 1
answered on 30 Aug 2007, 07:23 AM
Hi,
I exactly tryed your example because I simply dont bring any images to the screen. Using your example and some others that should work I always get this error message.
I use the current version and try to display the report within the Web Viewer.
Greetings,
Alexander Brütt
Serverfehler in der Anwendung /eyeView.
Der Wert darf nicht NULL sein.
Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde.
Ausnahmedetails: System.ArgumentNullException: Der Wert darf nicht NULL sein.
Parametername: encoder
Quellfehler:
Stapelüberwachung:
Versionsinformationen: Microsoft .NET Framework-Version:2.0.50727.832; ASP.NET-Version:2.0.50727.832
I exactly tryed your example because I simply dont bring any images to the screen. Using your example and some others that should work I always get this error message.
I use the current version and try to display the report within the Web Viewer.
Greetings,
Alexander Brütt
Serverfehler in der Anwendung /eyeView.
Der Wert darf nicht NULL sein.
Parametername: encoder
Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde. Ausnahmedetails: System.ArgumentNullException: Der Wert darf nicht NULL sein.
Parametername: encoder
Quellfehler:
Beim Ausführen der aktuellen Webanforderung wurde einen unbehandelte Ausnahme generiert. Informationen über den Ursprung und die Position der Ausnahme können mit der Ausnahmestapelüberwachung angezeigt werden. |
Stapelüberwachung:
|
Versionsinformationen: Microsoft .NET Framework-Version:2.0.50727.832; ASP.NET-Version:2.0.50727.832
0
Hi Alexander,
The issue can be solved by using the following code snippet:
The problem is that when the Bitmap is created from code its RawFormat is MemoryBmp which can't be saved in a stream. You first have to change the image format to a non memory one and just then pass the image to the picture box.
Kind regards,
Chavdar
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The issue can be solved by using the following code snippet:
using (Bitmap image = new Bitmap(100, 100)) |
{ |
using (Graphics dummy = Graphics.FromImage(image)) |
{ |
Font font = new Font("Arial", 18); |
dummy.DrawString("I am " + currentId, font, Brushes.Red, new RectangleF(0, 0, 100, 100)); |
} |
MemoryStream ms = new MemoryStream(); |
image.Save(ms, ImageFormat.Bmp); |
procPictureBox.ImageData = Image.FromStream(ms); |
} |
The problem is that when the Bitmap is created from code its RawFormat is MemoryBmp which can't be saved in a stream. You first have to change the image format to a non memory one and just then pass the image to the picture box.
Kind regards,
Chavdar
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Michael Helm
Top achievements
Rank 1
answered on 31 Aug 2007, 09:00 AM
Thank you,
that workaround works fine for me!
Regards,
Alexander
that workaround works fine for me!
Regards,
Alexander
0

manu
Top achievements
Rank 1
answered on 28 Apr 2008, 10:16 AM
Hi,
I have the same problem, Instead of showing image in detail section, I have to show image in group header section. I am showing report for different agency
(If I have 4 agency it will show one combine report separated by group header as well as group footer section). Image on group header section needs to change as agency changed. Can you please provide the sample code ASAP.
I also needs to email report as a attachement for agencies respective email Id that comes from database (need to email only that agency report part). Is it possible what i want to achieve in telerik report??
Looking forward.....
I have the same problem, Instead of showing image in detail section, I have to show image in group header section. I am showing report for different agency
(If I have 4 agency it will show one combine report separated by group header as well as group footer section). Image on group header section needs to change as agency changed. Can you please provide the sample code ASAP.
I also needs to email report as a attachement for agencies respective email Id that comes from database (need to email only that agency report part). Is it possible what i want to achieve in telerik report??
Looking forward.....
0
Hello Harendra,
You can achieve the requested functionality in many different ways. To show the image you will need a PictureBox report item placed in the group header section. It can be bound to a data field (e.g. PictureBox1.Value = "=Fields.AgencyImage" or PictureBox1.Value = "=Fields.AgencyImageUrl") which either contains the image data or the location of the image. Another possible way is to load the image in the ItemDataBound event of the PictureBox depending on some specific value read from the current DataItem. Which way you will choose depends on your specific project requirements. You can see sample implementations from the Demos installed with Telerik Reporting and from this thread.
To see how to send a report by e-mail you can refer to the following forum thread: Send a report by e-mail.
Hope this helps.
Best wishes,
Chavdar
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You can achieve the requested functionality in many different ways. To show the image you will need a PictureBox report item placed in the group header section. It can be bound to a data field (e.g. PictureBox1.Value = "=Fields.AgencyImage" or PictureBox1.Value = "=Fields.AgencyImageUrl") which either contains the image data or the location of the image. Another possible way is to load the image in the ItemDataBound event of the PictureBox depending on some specific value read from the current DataItem. Which way you will choose depends on your specific project requirements. You can see sample implementations from the Demos installed with Telerik Reporting and from this thread.
To see how to send a report by e-mail you can refer to the following forum thread: Send a report by e-mail.
Hope this helps.
Best wishes,
Chavdar
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

manu
Top achievements
Rank 1
answered on 29 Apr 2008, 10:25 AM
Thankx for reply..
but my problem is still not solved. I try the solution given by you, in my case i don't have image instead i have url for image. below is the error..
System.InvalidCastException: Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'. at InvoiceReportAll.groupHeaderSection1_ItemDataBound(Object sender, EventArgs e) in C:\SVNProjects\TMS\App_Code\InvoiceReportAll.vb:line 591 at Telerik.Reporting.ReportItemBase.RaiseEvent(Object key, Object sender, EventArgs e) at Telerik.Reporting.ReportItemBase.RaiseItemDataBound(Object sender, EventArgs e) at Telerik.Reporting.Processing.ReportItemBase.OnItemProcessed() at Telerik.Reporting.Processing.Report.ProcessGroup(DataRowView dataItem, Int32 level) at Telerik.Reporting.Processing.Report.ProcessData(DataView dataView, Int32 level, ProcessDataHandler dataHandler) at Telerik.Reporting.Processing.Report.ProcessData(DataView dataView, Int32 level) at Telerik.Reporting.Processing.Report.ProcessReportContent() at Telerik.Reporting.Processing.Report.ProcessItem() at Telerik.Reporting.Processing.ReportProcessor.ProcessReport(Report reportDefinition) at Telerik.Reporting.Processing.ReportProcessor.Render(String format, Report reportDefinition, Hashtable deviceInfo, CreateStream createStramCallback) at Telerik.ReportViewer.WebForms.ServerReport.Render(HttpResponse response, String format, Int32 pageNumber, Boolean refresh) at Telerik.ReportViewer.WebForms.ReportPageOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) at Telerik.ReportViewer.WebForms.HttpHandler.System.Web.IHttpHandler.Proc
my code is.....
Public Sub ReportBind(ByVal InvoiceId As String, ByVal BatchId As String, ByVal AccountId As Int16)
Me.CurrSum = 0
Dim objP As New PClsInvoice
Dim objInv As New ClsInvoice
Dim dtbl As DataTable
objP.InvoiceId = InvoiceId
objP.AccountId = AccountId
dtbl = objInv.PrintInvoiceAll(objP, BatchId) // returns data table contain report data
Dim row As DataRow
Dim Imageurl As New DataColumn("Imageurl")
Imageurl.DataType = System.Type.GetType("System.Byte[]")
dtbl.Columns.Add(Imageurl)
dtbl.AcceptChanges()
Dim en As New System.Text.ASCIIEncoding
For Each row In dtbl.Rows
row.BeginEdit()
row("Imageurl") = en.GetBytes(HttpContext.Current.Session("image" & row("AgencyId")))
row.AcceptChanges()
Next
Me.DataSource = dtbl
picAgencyLogo.Value = "=Imageurl"
End Sub
I call report bind method from .aspx page.
If I use " picAgencyLogo.Value = "=Imageurl"" with report sub constructor ... I cause error.. "Imageurl is not defined for this context".
thankx in advance
but my problem is still not solved. I try the solution given by you, in my case i don't have image instead i have url for image. below is the error..
System.InvalidCastException: Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'. at InvoiceReportAll.groupHeaderSection1_ItemDataBound(Object sender, EventArgs e) in C:\SVNProjects\TMS\App_Code\InvoiceReportAll.vb:line 591 at Telerik.Reporting.ReportItemBase.RaiseEvent(Object key, Object sender, EventArgs e) at Telerik.Reporting.ReportItemBase.RaiseItemDataBound(Object sender, EventArgs e) at Telerik.Reporting.Processing.ReportItemBase.OnItemProcessed() at Telerik.Reporting.Processing.Report.ProcessGroup(DataRowView dataItem, Int32 level) at Telerik.Reporting.Processing.Report.ProcessData(DataView dataView, Int32 level, ProcessDataHandler dataHandler) at Telerik.Reporting.Processing.Report.ProcessData(DataView dataView, Int32 level) at Telerik.Reporting.Processing.Report.ProcessReportContent() at Telerik.Reporting.Processing.Report.ProcessItem() at Telerik.Reporting.Processing.ReportProcessor.ProcessReport(Report reportDefinition) at Telerik.Reporting.Processing.ReportProcessor.Render(String format, Report reportDefinition, Hashtable deviceInfo, CreateStream createStramCallback) at Telerik.ReportViewer.WebForms.ServerReport.Render(HttpResponse response, String format, Int32 pageNumber, Boolean refresh) at Telerik.ReportViewer.WebForms.ReportPageOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) at Telerik.ReportViewer.WebForms.HttpHandler.System.Web.IHttpHandler.Proc
my code is.....
Public Sub ReportBind(ByVal InvoiceId As String, ByVal BatchId As String, ByVal AccountId As Int16)
Me.CurrSum = 0
Dim objP As New PClsInvoice
Dim objInv As New ClsInvoice
Dim dtbl As DataTable
objP.InvoiceId = InvoiceId
objP.AccountId = AccountId
dtbl = objInv.PrintInvoiceAll(objP, BatchId) // returns data table contain report data
Dim row As DataRow
Dim Imageurl As New DataColumn("Imageurl")
Imageurl.DataType = System.Type.GetType("System.Byte[]")
dtbl.Columns.Add(Imageurl)
dtbl.AcceptChanges()
Dim en As New System.Text.ASCIIEncoding
For Each row In dtbl.Rows
row.BeginEdit()
row("Imageurl") = en.GetBytes(HttpContext.Current.Session("image" & row("AgencyId")))
row.AcceptChanges()
Next
Me.DataSource = dtbl
picAgencyLogo.Value = "=Imageurl"
End Sub
I call report bind method from .aspx page.
If I use " picAgencyLogo.Value = "=Imageurl"" with report sub constructor ... I cause error.. "Imageurl is not defined for this context".
thankx in advance
0
Hi manu,
The exception is raised from the groupHeaderSection1_ItemDataBound subroutine. In it you are trying to get an Image object while the value is of type byte array(byte[]).
I suppose that the following line is also wrong:
Imageurl.DataType = System.Type.GetType("System.Byte[]")
If you are setting an Url for the PictureBox value it is most probably string, not byte array.
Kind regards,
Ivan
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The exception is raised from the groupHeaderSection1_ItemDataBound subroutine. In it you are trying to get an Image object while the value is of type byte array(byte[]).
I suppose that the following line is also wrong:
Imageurl.DataType = System.Type.GetType("System.Byte[]")
If you are setting an Url for the PictureBox value it is most probably string, not byte array.
Kind regards,
Ivan
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Madalin
Top achievements
Rank 1
answered on 07 Mar 2011, 03:27 PM
Hi,
I have an web application (ASP.NET with WCF service and silverlight clients) hosted on Windows Azure. I need to generate reports with images loaded dynamically from an URL (e.g. hostname/Image.aspx?imgID=....). I do this using Telerik.Reporting and rendering the report as PDF.
On my local development development machine everything works great and all images appear in the generated report.
However, when moving the application on production environment, the reports gets generated but each report picture box shows the following error instead of the image:
The web application runs on https with a self-signed certificate. If I try to load in browser same image url as in report, the image gets displayed ok.
Thank you,
Madalin Plastoi
I have an web application (ASP.NET with WCF service and silverlight clients) hosted on Windows Azure. I need to generate reports with images loaded dynamically from an URL (e.g. hostname/Image.aspx?imgID=....). I do this using Telerik.Reporting and rendering the report as PDF.
On my local development development machine everything works great and all images appear in the generated report.
However, when moving the application on production environment, the reports gets generated but each report picture box shows the following error instead of the image:
An error has occured while processing PictureBox 'pictureBox1':
The underlying connection was closed: Could not establish trust relationship
for the SSL/TLS secure channel.
The web application runs on https with a self-signed certificate. If I try to load in browser same image url as in report, the image gets displayed ok.
Thank you,
Madalin Plastoi
0

Kevin
Top achievements
Rank 1
answered on 03 Aug 2011, 01:59 PM
We had the same problem and were able to fix it by adding "127.0.0.1 www.sitename.com" to the host file of the remote server.
0

Vehbi
Top achievements
Rank 1
answered on 07 Jan 2015, 09:34 PM
An error has occurred while processing PictureBox 'pictureBox1': Could not find a part of the path System.Byte[]. ------------- InnerException ------------- Could not find file . This is happening when I am reading image saved in database as varbinary or image data type. Any solution?
0

KS
Top achievements
Rank 1
answered on 12 Jan 2015, 01:13 PM
Hi,
Why it is searching for a physical path after the image is taken from database? Post the code here.
-KS
Why it is searching for a physical path after the image is taken from database? Post the code here.
-KS