Thursday, November 27, 2008
by
Reporting Team
|
In some cases you might want to hide duplicates in a single "column" - for example if you group by a field, it would be nice to present the data in a more clean way e.g.:
Before:
column1 column2 column3
-----------------------------
phone nokia green
phone siemens brown
phone samsung red
car toyota black
car mitsubishi silver
After:
column1 column2 column3
-----------------------------
phone nokia green
siemens brown
samsung red
car toyota black
mitsubishi silver
Basically we should pass in the column1 (grouping) value and compare it to the last one we printed. If it's the
same, return an empty string and if it's different, we store and show the new value. We can declare a string variable to hold the value of the last-printed value in between item bindings.
The above scenario can be handled in two ways:
- Using DataBound event handler to modify the Value property of the TextBox.
- Creating user function to filter the value.
I have attached a sample solution with two reports that demonstrates both approaches. Please note the UserFunction should be public static (Public Shared in VB) and the old-value-storage should be static too.
I hope this helps someone and you enjoy this week's Reporting Tips & Tricks post!
[ReportingProcessDuplicates.zip]