Script report label to hide if image is included
I am generating a report, and if in image does not exist I would like a label to appear in its place that says "No Image Available". I would like to use the script functionality in the report designer to control this functionality. Does anyone have experience with this? Below is an example of what I would like to see:
string Image = rpt.Sections["detail"].Controls["imgAttachment"].Text as string;
if (Image.IsNullorEmpty)
{
rpt.Sections["detail"].Controls["lblImage"].Visible = false;
}
0
-
What's the source of the image? A URL, a local file on disk? 0 -
The image is generated in a repeating sub-report from image attachments in a table of an esri feature service. The report created creates repeating records from the table, and displays the image attached to that record. What I would like to do is if there is no attached image the picture control is set to invisible, and a label that says "No Image Available" is set to visible. I hope that answers your question! 0 -
Hi Andrew,
To access the .Text property of a control that has text, you must cast the control to its native type. The Controls[] array of a report section is an array of ARControl objects, which have only a few available properties (anything common to all controls, like position or visibility). So your code will work if you cast to a TextBox like so:
TextBox imgAttachment = (TextBox)rpt.Sections["detail"].Controls["imgAttachment"];
string Image = imgAttachment.Text;
You will have to stack the controls so that the "No Image Available" text appears once you remove the image, or you may want to toggle it on or off so that only one will appear.
Regards,
-Malcolm0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare