Chetan Pawar
Top achievements
Rank 1
Chetan Pawar
asked on 15 Jan 2010, 07:35 AM
Hello All,
the report columns I want are not specific so that I am generating them dynamically.
I have a query how to bind image column dynamically, i am trying to bind similar to text-box object. but images not shown.
Please provide way to add image column dynamically.
Thank you in advance.
the report columns I want are not specific so that I am generating them dynamically.
I have a query how to bind image column dynamically, i am trying to bind similar to text-box object. but images not shown.
Please provide way to add image column dynamically.
Thank you in advance.
8 Answers, 1 is accepted
0
Hello Chetan,
Here is a sample code:
Sincerely yours,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Here is a sample code:
private
void
pictureBox1_ItemDataBinding(
object
sender, EventArgs e)
{
Telerik.Reporting.Processing.PictureBox pic = (Telerik.Reporting.Processing.PictureBox)sender;
string
img = HttpContext.Current.Server.MapPath(
"img.jpg"
);
Image myImg = Image.FromFile(img);
pic.Image = myImg;
}
Sincerely yours,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chetan Pawar
Top achievements
Rank 1
answered on 15 Jan 2010, 10:03 AM
Hello,
Thank you for quick reply.
I am able to create report dynamically. Report contains, text box and image picture box column.
In some cases if record item does not contains image path (i.e. empty), then picture box in report displays as
An error has occured while processing PictureBox '':Access to the path 'D:\Project1' is denied."
Is there any property to set picture box blank, if image is not available.
Thank you for quick reply.
I am able to create report dynamically. Report contains, text box and image picture box column.
In some cases if record item does not contains image path (i.e. empty), then picture box in report displays as
An error has occured while processing PictureBox '':Access to the path 'D:\Project1' is denied."
Is there any property to set picture box blank, if image is not available.
0
Hi Chetan,
You state that you create the report dynamically (i.e. programmatically) so this means that you create and bind the items programmatically as well. In this line of thoughts it is up to you to make a check whether the image exists or not before assigning it to the PictureBox item.
All the best,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You state that you create the report dynamically (i.e. programmatically) so this means that you create and bind the items programmatically as well. In this line of thoughts it is up to you to make a check whether the image exists or not before assigning it to the PictureBox item.
All the best,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chetan Pawar
Top achievements
Rank 1
answered on 16 Jan 2010, 05:44 AM
Hello Steve,
Thank you for quick reply. There is small confusion, please see the following issue.
I am generating report from code.
consider following sample code
Telerik.Reporting.ReportItemBase[] rptItemDetail = new ReportItemBase[ds.Tables[0].Columns.Count];
report.DataSource = ds;
this.ReportViewer1.Report = report;
ReportViewer1.Width = Unit.Pixel(1280); //this.Request.Browser.ScreenPixelsWidth;
ReportViewer1.Height = Unit.Pixel(540); //this.Request.Browser.ScreenPixelsHeight;
ReportViewer1.DataBind();
Now if all images path is present in datasource column images dispalys well.
If perticular record do not contain a image path or empty record cell then in the report that image column cell shows error msg.
I want way to remove this error message.
Thank you for quick reply. There is small confusion, please see the following issue.
I am generating report from code.
consider following sample code
Telerik.Reporting.ReportItemBase[] rptItemDetail = new ReportItemBase[ds.Tables[0].Columns.Count];
for (int i = 0; i < ds.Tables[0].Columns.Count; i++) // imagin all columns have image path
{
string headcolumnname = ds.Tables[0].Columns[i].ColumnName;
Telerik.Reporting.PictureBox picboxh = new PictureBox();
picboxh.Value = "=[" + headcolumnname + "]";
picboxh.Width = new Telerik.Reporting.Drawing.Unit(220, Telerik.Reporting.Drawing.UnitType.Pixel);
picboxh.Height = new Telerik.Reporting.Drawing.Unit(50, Telerik.Reporting.Drawing.UnitType.Pixel);
rptItemDetail[i] = picboxh;
}report.DataSource = ds;
this.ReportViewer1.Report = report;
ReportViewer1.Width = Unit.Pixel(1280); //this.Request.Browser.ScreenPixelsWidth;
ReportViewer1.Height = Unit.Pixel(540); //this.Request.Browser.ScreenPixelsHeight;
ReportViewer1.DataBind();
Now if all images path is present in datasource column images dispalys well.
If perticular record do not contain a image path or empty record cell then in the report that image column cell shows error msg.
I want way to remove this error message.
0
Hi Chetan,
There is no confusion on the matter, simply get the path in a variable and check whether it exists or not before passing it as a value for the PictureBox item e.g.:
string imagePath = "=Fields.headcolumnname";
if (imagePath != null || imagePath != "")
{
picboxh.Value = "=[" + headcolumnname + "]";
}
Best wishes,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
There is no confusion on the matter, simply get the path in a variable and check whether it exists or not before passing it as a value for the PictureBox item e.g.:
string imagePath = "=Fields.headcolumnname";
if (imagePath != null || imagePath != "")
{
picboxh.Value = "=[" + headcolumnname + "]";
}
Best wishes,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Erik
Top achievements
Rank 1
answered on 21 Nov 2011, 04:18 PM
Steve,
Do you have this code in VB.net code?
Thanks!
Do you have this code in VB.net code?
Thanks!
0
Hadib Ahmabi
Top achievements
Rank 1
answered on 21 Nov 2011, 05:18 PM
Try googling VB to C# converter.
0
Michael
Top achievements
Rank 1
answered on 30 Nov 2011, 10:13 PM
I have a problem along the same lines but a little different.
I'm populating a picturebox in my report by setting the value to a filepath stored in my database. The value property of PictureBox1 is "=fields.filePath".
This works fine as long as that image path exists. I only insert a record in the database for an image if a user uploads it so after applying filters it's possible the record just doesn't exist. When this happens, the report doesn't render, it's totally blank. Not just the Picturebox but all fields are missing.
I've tried IIF(=Fields.filePath<>"", =Fields.filePath, \\server\defaultnotfound.gif). Also tried dumping the =Fields.filePath to a textbox to see what the current value is when the record doesn't exist but the report won't even start to render if the filtered dataset has no records.
Is there some other way to do this?
I'm populating a picturebox in my report by setting the value to a filepath stored in my database. The value property of PictureBox1 is "=fields.filePath".
This works fine as long as that image path exists. I only insert a record in the database for an image if a user uploads it so after applying filters it's possible the record just doesn't exist. When this happens, the report doesn't render, it's totally blank. Not just the Picturebox but all fields are missing.
I've tried IIF(=Fields.filePath<>"", =Fields.filePath, \\server\defaultnotfound.gif). Also tried dumping the =Fields.filePath to a textbox to see what the current value is when the record doesn't exist but the report won't even start to render if the filtered dataset has no records.
Is there some other way to do this?