[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to pass an object to ReportViewer WinForm control in VS 2008 ?

Posted on 2010-11-16
6
Medium Priority
?
606 Views
Last Modified: 2013-11-26
I have a WinForm with ReportViewer control and I need to pass some data
to the report I created. It's just few variables, not data from db.

How can I pass my custom object to my report ?

I think I'm looking for something like :

this.reportViewer1.RefreshReport(myObject);
or
this.reportViewer1.PassObject(myObject);
or whatever,
so I can somehow use this object in rdlc file .

0
Comment
Question by:shlafrock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 1

Expert Comment

by:RADONE242
ID: 34149645
What type of object? Can it be added as a data source? Perhaps you can just pass values from your object as parameters?
0
 
LVL 1

Author Comment

by:shlafrock
ID: 34149678
ok, so how do I pass values as parameters?
0
 
LVL 1

Author Comment

by:shlafrock
ID: 34149783
i think i got it :
            List<ReportParameter> paramList=new List<ReportParameter>();
            paramList.Add(new ReportParameter("TestPass", "10"));
            this.reportViewer1.ServerReport.SetParameters(paramList);
            this.reportViewer1.RefreshReport();  

but now how do I access these parameters in rdlc file ?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 1

Expert Comment

by:RADONE242
ID: 34149808
First add your parameters to the report. Click Reports from the file menu, then report parameters.
Next from your form with the report, dim an array for the parameters you wish to pass

        Dim parItems(2) As ReportParameter
        parItems(0) = New ReportParameter("Parameter1", MyObject.FirstName)
        parItems(1) = New ReportParameter("Parameter2", MyObject.LastName)
        parItems(2) = New ReportParameter("Parameter3", MyObject.Address)

Then before refreshing the report add your parameters

Me.ctlReportViewer.LocalReport.SetParameters(parItems)

0
 
LVL 1

Accepted Solution

by:
RADONE242 earned 2000 total points
ID: 34149830
=Parameters!TestPass.Value
0
 
LVL 1

Author Closing Comment

by:shlafrock
ID: 34149935
perfect. thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question