dynamic image in rdlc not appear correctly - c#

I have this hirarcy in my project
Report forlder -> Image Folder , Reports -> Rdlc
in rdlc I set the image source to external and use parameter
when add the parameter to report call the report not appear
I write the parameter like
"file:images\icon.jpg" is there an certain extension to use or why this cause the report to not appear ,I tried to remove the image and the report work fine

you should pass the complete image path to your image in this way if you pass it like you've done I don't thik it will work.
ReportViewer1.LocalReport.EnableExternalImages = true;
ReportViewer1.LocalReport.SetParameters(new ReportParameter("image", "file:///" + Server.MapPath("~/images/icon.jpg",true));

Related

Logo image not displaying in Crystal Report Subreport C# ASP.NET MVC

I am new to Crystal Reports in ASP.net MVC. I have a main report with a logo from a subreport. The subreport is a separate .rpt file that gets its data from an image saved in the database in a binary string format. This logo's datatype when checked in the xsd is String.Byte[].
However, when I run the report viewer in the web browser, no image is being displayed. Even when I click on the box of the logo in the web browser and the separate rpt file is loaded, the report is blank.
I can confirm that this specific logo saved in the DB can be displayed in the report viewer when I tried to add a column for the image in the stored procedure that is used to populate and dragged that field in my main report.
I hope someone can help me as I am stuck here for days. This is what my code looks like in the report viewer:
report.Subreports["Logo"].ReportDefinition.ReportObjects[0].Height = 1500; //Convert.ToInt32(reportParam.CRParameters["COMPANYLOGOHEIGHT"]);
report.Subreports["Logo"].ReportDefinition.ReportObjects[0].Width = 5250; //Convert.ToInt32(reportParam.CRParameters["COMPANYLOGOWIDTH"]);
report.Subreports["Logo"].ReportDefinition.ReportObjects[0].Left = 13;
report.SetDataSource(reportParam.DataSource["Table"]);
report.Subreports["Logo"].SetDataSource(reportParam.DataSource["Logo"]);
StatementOfHoldingsReport.ReportSource = report;
I believe I am missing something when the image is being displayed in the separate sub report. I can also confirm that the string of bytes can be found in the row of the reportParam.DataSource["Logo"].

load dynamic image from path in crystal report

I want to show an image in my report , I save path of image in my sqlserver database and now I want to load image from path .I search all of internet for that and try all of guidance , I first insert image into my report and after that I go to >Format Editor > picture > Graphic Location > and insert path of image into the textarea like this {Command.path} but when I run , it doesn't show any picture . Now how should I do ?
I use visual studio 2013 and latest version of crystal report .
Use a conditional formula to dynamically change the location of a report’s image.
1. Add an image to the report: -> Insert -> Picture
This image will act as a placeholder.
Ensure that the placeholder is the same size as the one that will be dynamically loaded, otherwise, the image will be scaled.
2. Change the image’s Graphic Location:
->right click image
->select Format Graphic…
->select Picture tab
->click the conditional-formula button (looks like x+2)
->set the formula’s text to the name of the formula or parameter field that will contain the image’s URL
->save the formula and click the OK button
->Save the report
It worked for me.
Source: cogniza.com
You can actually do it by:
Add a datasource for your report. Be sure to include the path image.
Add a default image.
From Format Editor > picture > Graphic Location , add the path image field.
According to this, you're doing it right. Perhaps try to set a formula field equal to {Command.path} and use that instead to see if crystal just isn't parsing it properly? That way you can display the formula field and see how it displays. Perhaps you're storing it in the DB with quotation marks or spaces? Alternatively, using a parameter should definitely work, so you could make a sub-report with {Command.path} as a parameter that it uses to load up the image.

How to fix image on Report.rdlc by giving path?

I don't want save image in database. My application going to work on different shops i want show their logos on report.rdlc. For that i want to know, can i show image on report.rdlc by using path of image only? I tried to create parameter for Report.rdlc in ReportData but there is not any image Datatype.
Yes, you can:
Set image Source to External
Set image Value to an URL or file path
Set EnableExternalImages=true in your report code
You can also refer to http://msdn.microsoft.com/en-us/library/ms251715(v=vs.80).aspx for some additional info, but those steps above must be enough.

How to pass textbox/Combobox value to rdlc report text field?

c#, mysql in my project.
In that i create a rdlc report. I dont know to pass winform textbox value to rdlc report text field.
I googled and try some set of code. but cant get that.
If you worked in report. please help me.
My requirement is,..
I am doing college project. In that they asked bonafide certificate. So i create a winform With reportviwer, name, course, year, semester, academic year, purpose textboxs and one button. Click the button when the textboxes are filled. those text values want to pass the record textboxes.
Is it possible any way.
my report...
Set the parameters using LocalReport property in the Report Viewer
C# Code :
ReportParameterCollection reportParameters = new ReportParameterCollection();
reportParameters.Add(new ReportParameter("ParameterName", "Value"));
this.reportViewer.LocalReport.SetParameters(reportParameters);
One way would be to setup a parameter for each of the fields you want to bring in and set the value of the parameter to whatever you want in your C# app. In the report you would then set the value of each text box to be the parameter and it should work just fine.
Or if you are using RDLC files (which you are) you could put your data into a dataset and pass that to the report and then have each field in the report a column in the dataset
1) Create parameter in RDLC Report.
2) Place the parameter Where you want in the RDLC Input Textbox property.
3) Type the below code in Reprot.cs page.
4) Passing the parameter value where you redirect the Report page.
ReportParameter[] parms = new ReportParameter[n];
parms[0] = new ReportParameter("param_name", textbox(n-1).text);
parms[1] = new ReportParameter("param_course", textbox(n).text);
this.reportViewer1.LocalReport.SetParameters(parms);
this.reportViewer1.RefreshReport();
following method worked for me i used vb.net2010
1: In Visual Studio 2010, open your .rdlc file, and open “Report Data” window (If you can not see this window, go to View menu to open it);
2: Right click the “Parameters” node, and add a new Parameter, ie: named it “startdate“;
3: In your .rdlc file, add a textbox, named it tbContent, and set its filed express to :
=Parameters!startdate.Value
4: Go to your Form file which include your reporterview control, and add the following code:
Dim rptparameter As ReportParameter
rptparameter = New ReportParameter("content", txt_startdate.Text)
rv_param.LocalReport.SetParameters(New ReportParameter() {rptparameter})
rv_param.LocalReport.Refresh()

A data source instance has not been supplied for the data source

I'm currently trying to dynamically send an rdl report to my ReportViewer .net object.
I keep getting the error when I do it: A data source instance has not been supplied for the data source "blah"
I'm trying to define "blah" in my code behind at runtime.
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = ReportFile;
ReportViewer1.LocalReport.DataSources.Clear();
Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
rds.Name = "blah";
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.DocumentMapCollapsed = true;
ReportViewer1.LocalReport.Refresh();
this is not working by a long shot. I'm not sure what I'm supposed to do. here is an extract of the top of my rdl file:
<DataSource Name="blah">
<rd:DataSourceID>c6a8409e-71a4-4e96-86ad-b300a5b942c3</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>Data Source=10.555.121.121;Initial Catalog=blah</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>
All I'm trying to do is simply select * from a table in "blah" in my report. I need this to work because I have many other report instances I need to show inside my ReportViewer. Why doesn't Microsoft make this easier?
Thanks in advance anybody...
The ReportViewer control is designed to work in local mode with RDLC report files, not RDL report files. The ReportViewer control is only intended to render the report and therefore ignores any dataset and connection information that may be present (i.e. if you use an RDL file instead of an RDLC file). The intention is that you create any connections, query data sources, put the results in DataTables and add these to create the reportDataSource(s) for the reportViewer control in the calling application.
From MSDN:
In local processing mode, the control opens a report definition,
processes it, and then renders the report in the view area. In local
processing mode, you can get the report definition from a .rdlc file
on the file system, from a stream, or from an embedded resource in
your application.
More information: Adding and Configuring the ReportViewer Controls
See also: When to use RDLC over RDL reports?

Categories