Solved

Reportviewer rdlc .net parameters

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

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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 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.

770 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