Search code examples
asp.netcssrepeater

Asp.Net repeater format item based on previous record


I have a thorny little problem where I am outputting an audit trail and need to highlight the changes to each record.

I am currently using a Linq-to-Sql data source to pull the audit data back and then displaying it in a table using a repeater which works fine.

The problem is I need to change the background colour of a cell if its value has changed from the previous record and I'm struggling to find a way to do this.

An alternative I've considered is to simply generate the whole table which will work but I just get the feeling there must be an easier way to do this.

Any thoughts?


Solution

  • After must playing about I found that it was quickest to generate the html manually.

    I forgot to mention in the original question that I had to reverse the order to the records (i.e. most recent first) and therefore it became even more difficult to style the record in a repeater event e.g. add first record which has to have colour coded cells to indicate changes but at this point the next record hasn't been written so you have nothing to compare against.

    The easiest way seemed to be to loop through the records in the code behind and do the comparison there property to property and then to create the html with styling based on that.

    Thank you to everybody who took the time to look at the question and suggest solutions.