Last post Jul 20, 2014 07:57 AM by sjnaughton
Jul 18, 2014 05:35 PM|bspeake|LINK
I have a requirement to display the List.aspx GridView in grey (for example) when a user isn't in the role needed for data editing. I have been Googling all day, and haven't found a solution yet. I understand the IAutoFieldGenerator interface with the
GenerateFields() method can be used to cycle through each column. When I tried that approach, the GenerateFields() method never fired. My application is .NET 4.5, and I think that approach is for an older version of dynamic data.
I want to decorate each column with something like:
Then, as the mark-up is being generated, compare the user's role to the one applied to the column.
I can think of a way to do this, but it isn't very "dynamic data", and it requires modifying List.aspx.cs, which I want to keep to a minimum. Please help.
Jul 18, 2014 05:43 PM|batman1482|LINK
The entire gridview needs a style change based on the user's role? If so, couldn't you just check their role before loading the gridview and assign the proper css class? For example, in your css, you could have a gridview-admin class and a gridview-nonadmin
class, or something of the sort. In your cs code (if willing to modify it), you'd have something like:
if (role == "Admin")
GridView1.CssClass = "gridview-admin";
GridView1.CssClass = "gridview-nonadmin";
Jul 20, 2014 07:57 AM|sjnaughton|LINK
Hi bspeake, you have to use the auto field generator in the Page_Load event. also you may want to look at my articles here: