문제

I have made a RDLC report which generates its tablix from the dataset I provided. I need the content of cell(each Textbox in Tablix) to change its backColor based on its content.

Eg:

Name | Val  
Joe  | 80  
Lee  | 60  
Fred | 30  
Bill | 57  

I have a condition that less than 60 should change its backcolor to red. (so, 30 and 57 will be getting its backcolor as red).

Note: Since it loads from dataset, you cannot set it directly. Is there any way if we pass conditions as parameters to rdlc and work on its own??

도움이 되었습니까?

해결책

Use an expression in the background property. You can get the current value of some field that you've read in using: Fields.Name_Of_Field.Value, it will automatically move to the correct one on each row.

if you have single test you can use this

=IIF(Fields.Val.Value < 60, "Red", "Blue")

if you have multiple test you can use this

=SWITCH(
 Fields.Val.Value < 60, "Red",
 Fields.Val.Value < 80 && Fields.Val.Value >= 60, "Blue",
         .
         . add other tests here
         .
 "Black") ' default is black in case all the tests fail

One of the great things about RDL is the number places you can use expressions. Try this for a starter

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top