hide columns dynamically in rdlc report

前端 未结 3 1141
孤城傲影
孤城傲影 2021-02-20 05:03

How we can hide columns dynamically in rdlc reports in MVC 2?

Is it is possible using external parameters? How we can programmatically control the visibility of columns

3条回答
  •  不思量自难忘°
    2021-02-20 05:35

    Following are the steps to hide the column

    1) Add a boolean parameter with name column_visible in your report

    2) Right Click on desired column and select Column Visibility.

    3) Select the option "show or hide based on an expression"

    4) add following formula

    = iif(Parameters!column_visible.Value = "True", false,true)
    

    5) Add following code in c# file where you are assigning value to above added parameter

    ReportParameter[] parameters = new ReportParameter[1];
    if (condition)
    {
       parameters[0] = new ReportParameter("column_visible", "True");
    }
    else
    {
     parameters[0] = new ReportParameter("column_visible", "False");
    }          
    this.reportViewer1.LocalReport.SetParameters(parameters);
    

提交回复
热议问题