Hoppa till huvudinnehållet

How can change the Photo in Report based on selection

Kommentarer

3 kommentarer

  • Permanently deleted user

    You'll have to use code-behind in the ActiveReports file to concatenate the link with the data and load the photo into a picture control. Other than the fact that it needs to be coded, there is no reason that you cannot do this.

    0
  • Permanently deleted user

    Josh has probably figured this out by now, but I thought I'd post this for anyone else who is trying this.

    So you have a report that shows a feature and the feature has an associated photo that gets retrieved from a website url.  How do you get that in a report?

    the following site provided the answer

    *******************************

    From the Datadynamics forums: http://www.datadynamics.com/forums/85601/ShowPost.aspx

    Ah, this is the key difference.  Image.FromFile and new Bitmap( filename ) don't support loading from a web address.  You will have to figure a way to load the image from the URL before assigning it to the picture.Image property.  I've changed the code in Detail_Format to load the image from the web.  I did a quick test with both http and https urls and it seems to work.

    ********************************

    You can take the parcel.rpt that Geocortex provides and modify it so that it works with your data.  To get that picture to show a photo from a web address, you add the following code to the script - you'll see on the bottom of report designer that there are 3 tabs - designer - script - preview - select the script tab.

    Your detail section might be called something else like Detail1 but mine was called detail  

    public void detail_Format()

     

    {

     

       

     

        string pin_value = Convert.ToString( rpt.Fields["PIN"].Value);

     

        string pictureUrl ="http://getMeMyPhoto.com/getbin.php?type=pic&parcel=" + pin_value;

     

      

     

        //Setting up the image to retrieve webrequest

     

        System.Drawing.Image pinImage = null;

     

        System.Net.WebRequest req = System.Net.WebRequest.Create( pictureUrl );

       using( System.Net.WebResponse response = req.GetResponse() )

     

       using( System.IO.Stream stream = response.GetResponseStream() )

     

       {

     

       pinImage = System.Drawing.Image.FromStream( stream );

     

       }

        //PictureProperty is the name of the Picture control - your's might be a different name

        Picture PictureProperty = rpt.Sections["detail"].Controls["PictureProperty"] as Picture;

     

        PictureProperty.HyperLink = pictureUrl;  

     

        PictureProperty.DataField = pictureUrl;

     

        PictureProperty.Image = pinImage;

    }

    When I would run the report by selecting preview, I'd get an invocation error - but when I tried it in the application and it worked. 

    Hopefully this will help others.

    0
  • Permanently deleted user

    Pardon my ignorance but how is that subroutine called?

    Is it an event?

    0

Du måste logga in om du vill lämna en kommentar.