RDLC报表:如何在条件不满足时隐藏行?当前IIf返回0需调整
Solution to Hide RDLC Rows When Condition Fails
Instead of returning 0 in your value expressions, you can control the visibility of the entire row directly using RDLC's Row Visibility property. Here's how to adjust your setup for each of your rows:
Step-by-Step for Each Row
Let’s start with the row tied to OrderTypeId = "1"—repeat these steps for the other two rows (just tweak the condition each time):
- Select the target row: Click the small gray row handle on the left side of the row (this selects the entire row, not just a single cell).
- Open visibility settings: Right-click the row handle and choose Row Visibility from the dropdown menu.
- Use an expression to control visibility: In the dialog that appears, select the option Show or hide based on an expression.
- Enter the visibility logic: For the row checking
OrderTypeId = "1", paste this expression:
This tells RDLC: "If the OrderTypeId isn't '1', hide the row (True = hidden); otherwise, show it."=IIf(Fields!OrderTypeId.Value <> "1", True, False) - Repeat for other rows:
- For
OrderTypeId = "2", use:=IIf(Fields!OrderTypeId.Value <> "2", True, False) - For
OrderTypeId = "3", use:=IIf(Fields!OrderTypeId.Value <> "3", True, False)
- For
Bonus: Simplify Your Value Cells
Now that the row is only visible when the condition is met, you can ditch the IIf in your value cell entirely. Replace those expressions with just:
=Fields!Orders.Value
Since the row won’t render unless the OrderTypeId matches, you don’t need to handle the 0 case anymore.
内容的提问来源于stack exchange,提问作者john
相关产品推荐
相关产品推荐

