Dynamically Add and Display External Image in RDLC Report From Code Behind in ASP
Dynamically Add and Display External Image in RDLC Report From Code Behind in ASP
aspx
Home
Categories
1 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
2 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
3 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
Forums
Contact
Search
Here Mudassar Ahmed Khan has explained how to show external images to RDLC Report in ASP.Net.
The path of the external image will be dynamically set from code behind using Report parameter.
4 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
In this article I will explain how to show external images to RDLC Report in ASP.Net. The path of the external image will be dynamically set from code behind using Report parameter.
2. Now add a Parameter to the RDLC Report of type text and set its name.
5 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
Set its name, ToolTip to be displayed and make sure you select the Image Source as External. Next we need to set the following formula which means that path of the image will be fetched from the ImagePath Report Parameter we have added in step
#2.
=Parameters!ImagePath.Value
Then in the Size Tab you need to set the Display property as Original Size.
6 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
HTML Markup
The HTML Markup consists of ASP.Net ScriptManager and ReportViewer control.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server">
</rsweb:ReportViewer>
</form>
</body>
</html>
Namespaces
You will need to import the following namespaces.
C#
using Microsoft.Reporting.WebForms;
VB.Net
Imports Microsoft.Reporting.WebForms
7 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
{
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
ReportViewer1.LocalReport.EnableExternalImages = true;
string imagePath = new Uri(Server.MapPath("~/images/Mudassar.jpg")).AbsoluteUri;
ReportParameter parameter = new ReportParameter("ImagePath", imagePath);
ReportViewer1.LocalReport.SetParameters(parameter);
ReportViewer1.LocalReport.Refresh();
}
}
VB.Net
Once you execute the application you should be able to view the external image in RDLC Report as shown below.
Now in spite of following all steps if you still do not see the report and you see a cross image icon on the RDLC Report, then you need to follow the following procedure.
You will need to make sure that either both or one of the following Handlers are added to the Web.Config file.
1. Add the following to <system.web> => <httpHandlers> section.
<add verb = "*" path = "Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, Publ
icKeyToken=b03f5f7f11d50a3a" />
8 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
<add name = "ReportViewerWebControlHandler" preCondition = "integratedMode" verb = "*" path = "Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, M
icrosoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Note: If you don’t have both sections in your Web.Config then you can add only to the one you have.
Demo
View Demo
Downloads
Download
9 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
More
You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment
Please note that all comments are moderated and will be deleted if they are
10 of 11 18/01/2016 2:44 PM
Dynamically add and display external Image in RDLC Report from code behind in ASP.Net http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
Name
Comment
Security code:
Add Comment
Katheeja
This site is like Google for asp.net developers. Simple and worthy..
Petros
The simple ones are the best just plug in a few lines of code and it does the job complete as well demo and source available
PeteO
75 other websites... all with same example that did not work then I found yours. Thank you for your hard work.
Iron
You are number one. Thanks.
samruddhi
Really awesome and very helpful site ever.....
Subscribe
Subscribe
© 2016 www.aspsnippets.com All rights reserved | Privacy Policy | Powered by Excelasoft Solutions
11 of 11 18/01/2016 2:44 PM