Solved

Reportviewer rdlc .net parameters

Posted on 2011-03-03
8
1,304 Views
Last Modified: 2013-11-26
1)I am adding paarmeters to reportviewer.

Code: 2 ways -both giving smae error
        private void setRepParam()
        {
            ReportParameter[] RptParameters = new Microsoft.Reporting.WinForms.ReportParameter[2];//declare the number of parameters
            string strTrxx = ddTrxx.SelectedItem.ToString();
            string strYear = ddYear.SelectedItem.ToString();
            RptParameters[0] = new Microsoft.Reporting.WinForms.ReportParameter("YEAR", strYear,false);// first parameter
            RptParameters[1] = new Microsoft.Reporting.WinForms.ReportParameter("TR_XX", strTrxx,false);//second parameter
            try
            {
            this.reportViewer1.LocalReport.SetParameters(RptParameters);
            this.reportViewer1.LocalReport.Refresh();
            this.reportViewer1.Show();
            this.reportViewer1.RefreshReport();
            }
            catch (Exception e)
            {
                throw (e);    
            }
          }
        private void SetReportParameters()
        {
            string strTrxx = ddTrxx.SelectedItem.ToString();
            string strYear = ddYear.SelectedItem.ToString();
           
            ReportParameter yearParameter = new ReportParameter("Year",strYear);
            ReportParameter trGrpParameter = new ReportParameter("Trade_Owner", strTrxx);
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { yearParameter, trGrpParameter });
        }
2)Did select rdlc report and add parameters to it through the builder.
3)But still --
If I add this --this.reportViewer1.LocalReport.Refresh(); no report appears
If I write --this reportViewer1.ReportRefresh()---original report appears without any filter based on parameter..
How do I make parameterized reports run ?????

0
Comment
Question by:rishaan
  • 4
  • 3
8 Comments
 
LVL 13

Assisted Solution

by:agarwalrahul
agarwalrahul earned 100 total points
ID: 35034184
0
 

Author Comment

by:rishaan
ID: 35069490
Thanks..I tries the 3 steps---
1)Creating report parameter in the rdlc report
2)Changed the Fields!XX.Value in textbox  to Parameters!xx.value ----in rdlc report
3)Added reportparamters to reportviweer.localreport.paarmeters.add(..) in .net code...
Now I can run report and see the results but the result is just replaced by that value eg. ASIA
Everwhere the fileds!XX value is is replaced by PArametr entered.
Its not actually filtering records...WHAT AM I Missing ???
0
 
LVL 5

Accepted Solution

by:
puffdaddy411 earned 150 total points
ID: 35072478
It sounds like you are attempting to filter a reportviewer table using your parameter.  You need to open the Table Properties dialog box and select the "Filters" tab.  Under "Expression", select the column on which you need to filter.  Select your desired operator.  Under "Value", your expression should look like "=Parameters!xx.value".

In your previous step #2, you need to revert that change.  Ensure "=Fields!XX.Value" is in your textbox.

If you are using a reportviewer List object, this will work the same using the list properties window / Filters tab.
0
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!

 

Author Comment

by:rishaan
ID: 35074393
reportviewer table dialog bo x ?how to open ?

0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 35074627
Select the entire table, right-click the table border, and select properties.
0
 

Author Comment

by:rishaan
ID: 35083155
GREAT!!!!!!!!!!!!!!!!!!!!!!!It works like   charm..................................................
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 35083170
Very good!  =D
0
 

Author Closing Comment

by:rishaan
ID: 35083175
THANKS A LOT for the quick and perfect response..
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TFS 2015 Access denied. 1 30
C# XML Get Values 4 37
Nested forach loop to linq 3 30
C# MDI - Use Button on Child Form to Open (or Show) a Different Child Form 3 24
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

730 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