Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...