Solved

Reportviewer rdlc .net parameters

Posted on 2011-03-03
8
1,294 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
 

Author Comment

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

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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 use and create new code templates in NetBeans IDE 8.0 for Windows.

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now