views:

99

answers:

1

I have a gridview (DXperience gridview) where I would like to display if the user has already clicked on a link in that row. The link on each row sends the user to a page where more detail is shown about the item. To symbolize this I have thought of e.g. making the background of the visited rows in a different colour.

My question is what is the easiest and most efficient way to do this?

My Idea: Since there is no login system I have thought of saving the IDs of the items in a cookie seperated by comma, and when rendering the rows I will look in the cookie to see if that item is already viewed.

I have a concern on how slow this will make the gridview. I am usually displaying a few thousand rows and if the user has clicked on maybe 40 items, it will take a while to run through 40 items on each row, to check if it is already viewed. Is this a valid concern, and if yes, how could I optimize it?

A: 

There are a couple of ways you could do it. Using the cookie is one valid way, though it will probably not allow for a clean use of :visited.

This person changed the address on binding, so it matches to a unique ID. link They had a problem with coloring in IE7; I suspect this is because they had to use an anchor (#).

Update:

Depending on your situation you could try passing a list of row IDs to a literal:

var visitedSites = <asp:Literal />;

Pass in a JS array and you can loop through it and set the row colors that way. It's not especially high overhead, at least not until you get past a few hundred links visited.

You can also do this on the server side, during row bind. Depending on server vs. client load, this may be the better option.

function gridLinks_OnRowDataBound (...) {
    if (visited.Contains(e.Row.DataItem["field"]))
    //Set color
}

(I'm working from memory and don't use C# at work, but you get the general idea.)

Chris
My row contains multiple columns, and I would like to make the background of the complete row and not just the one column which links to the item, a distint colour, if visited.
Dofs
One thing you could do is loop through the rows, and set the row color by the link color. But there's a good chance that reading visited color will not always work, because it's a security hole (http://www.azarask.in/blog/post/socialhistoryjs/)
Chris
I would go for populating a hidden field with JS data on the visited rows. Architecturally speaking, it's a simpler option.
Chris