Report reportviewer binding image-rdlc

Source: Internet
Author: User

Use external images or database images in reports

By default, external images cannot be used in reportviewer reports. To use an external image, you mustCodeSet inEnableexternalimagesAttribute. To see how to specify an external image example, seeExample: Use RSS source in reportviewer.

To use database images, you can specify the database fields that contain images when the MIME type is JPG, PNG, or BMP. If an image is stored as a binary object, you must write an expression to convert the image to a supported type.

 

The processing process of the field [ImagePath] is to read the image with stream before binding, convert it to the byte [] array, and finally convert itBase64string, and then bind

 

// Strem numeric Dataset

Public static byte [] streamtobytes (Stream stream) {byte [] bytes = new byte [stream. length]; If (stream. canread) {stream. read (bytes, 0, (INT) stream. length);} stream. close (); Return bytes;

}

 

In the report rdlc. Drag and Drop an image control in the report body. Set its source to database,Value = system. Convert. frombase64string (Fields! Barcode. Value) [byte [] array], which can be directly bound to the base64string type. // Key.

Set the mimetype attribute. In this way, your images can be dynamically displayed in the report.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.