在 RDLC 报告中动态隐藏列

发布于 2024-11-16 09:33:15 字数 81 浏览 8 评论 0原文

我们如何在 MVC 2 的 rdlc 报告中动态隐藏列?

是否可以使用外部参数?我们如何以编程方式控制 rdlc 报告中列的可见性?

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 in rdlc reports?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

木緿 2024-11-23 09:33:15

您不想使用Hidden 属性,您实际上想要选择该列,右键单击并选择Column Visibility。进入此处后,您可以使用表达式根据参数设置可见性,如下所示:

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

Hidden 在此实例中不起作用,因为您实际上并未将其应用到像您这样的对象当您选择文本框之类的内容时。

You don't want to use the Hidden property, you actually want to select the column, Right Click and select Column Visibility. Once in here you can use an expression to set the visibility based on a parameter, something like this:

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

Hidden doesn't work in this instance because you're not actually applying it to an object like you are when you select something like a textbox.

薄凉少年不暖心 2024-11-23 09:33:15

以下是隐藏列的步骤

1) 在报告中添加名为“column_visible”的布尔参数

2) 右键单击​​所需列并选择“列可见性”。

3) 选择“根据表达式显示或隐藏”选项

4) 添加以下公式

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

5) 在 c# 文件中添加以下代码,在其中为上述添加的参数赋值

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);

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);
甚是思念 2024-11-23 09:33:15

选择一列。在属性中,您有隐藏。财产。然后您可以设置一个条件,例如=Parameters!IsColumnHidden.Value

如果您想从 C# 代码执行此操作,我会向报告发送一个参数(如上所示),说明是否应隐藏列。

Select a column. In properties you have Hidden. property. Then you can set a condition, for example =Parameters!IsColumnHidden.Value.

If you want to do this from C# code I would send a parameter (like above) to the report saying if column should be hidden.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文