DataGrid Item Highlighting

rcaine

Newcomer
Joined
Mar 9, 2005
Messages
6
Hi,

I'm trying to use alternate row colouring but I have an additional problem. If an item is missing certain data, I want to hide it from normal users or colour it pink for admin users.

The problem is if I hide the row, it messes up the alternate colouring on the grid. That is, instead of getting blue-white-blue-white, I get blue-white-white-white-blue because the row that should have been blue has been hidden.

I need to some how remove the rows before the render event so that the alternating colour scheme still works. Any idea how this might be achieved?

I've looked around on the web and seen potential methods which involve the prerender event or the itemDataBind event, but am unsure if this is what I need or if they are appropriate. Any ideas and or sample code would be greatly appreciated - I'm pretty stuck...

Thanks in advance,

Rich
 
Load your data into a datatable, for regular users, delete empty rows, for admins leave them in there, then bind your datagrid to this datatable
 
Thanks.

I eventually fixed the problem by using a dataview and using .RowFilter if they weren't admins.

Because I was also allowing sort on the datagrid, I had to use the datagrid's prerender event to do my highlighting (otherwise as soon as an admin sorted the grid, the pink highlights would disappear ;-))

I overrode the datagrid's prerender eventhandler to colour the rows pink by re-cycling through the dataview. This had to be surrounded in a try catch in case the row ref wasn't there (because I could have filtered out some rows).
 
Back
Top