Link to home
Start Free TrialLog in
Avatar of rishaan
rishaan

asked on

Reportviewer rdlc .net parameters

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 ?????

SOLUTION
Avatar of Rahul Agarwal
Rahul Agarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rishaan
rishaan

ASKER

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 ???
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rishaan

ASKER

reportviewer table dialog bo x ?how to open ?

Select the entire table, right-click the table border, and select properties.
Avatar of rishaan

ASKER

GREAT!!!!!!!!!!!!!!!!!!!!!!!It works like   charm..................................................
Very good!  =D
Avatar of rishaan

ASKER

THANKS A LOT for the quick and perfect response..