?
Solved

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

Posted on 2010-11-16
6
Medium Priority
?
605 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

777 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