Hi, I have a corporate asp.net application - access to application is restricted to members of a particular AD group on domain. There are two types of user - ones which have read-write access and ones which have read only access. I have database table containing usernames and column indicating if they are read-only user or not. I use a combination of Windows authentication and custom principal/identity classes to assign a "IsReadOnly" property to user's identity. So far so good.
I am displaying records in GridView - for two of the columns in the grid, I need to display either a hyperlink field (for read-write users to click on) or a text field (for read-only users, so they can see values, but not click on). I need to figure out a way of swapping the hyperlink for a text field at runtime. The grid currently uses databound hyperlink fields, which I disable at runtime in the grid's RowDataBound event handler:
// code to get user's identity omitted for brevity
if (identity.IsReadOnly)
{
e.Row.Cells[2].Enabled = false;
e.Row.Cells[3].Enabled = false;
}
but this disables the hyperlinks so that the text appears greyed out - not the effect I want. I want the text to appear normal - just not as a hyperlink. Any ideas? Have seen similar posts suggesting using a template field - is this the only way? If so, where can I find good examples?