Thks for that, I'll be implementing some kind of role based security in my project soon and I wanted to look at your example with more detail to decide how to do it.
One thing I noticed is the use of IAutoFieldGenerator to display/hide fields depending on the Permissions. Well, in my case I had to set the autoGenerateRows/Columns to false and manually add <asp:DynamicDataField> because I wanted to change the order in which fields appear and also don't show some of them in Insert or Edit mode (auto-filled values, for example).
The question is if there's some way I can do this whole "security using roles" thing in the way I have it set up (with rows/columns not generated automatically) and without doing it all manually, like:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (!Roles.IsUserInRole("Administrator"))
{
LinkButton deleteLink = e.Row.FindControl("DeleteLinkButton") as LinkButton;
deleteLink.Visible = false;
}
}
}And how can I hide a DynamicDataField programatically based on roles?
Thks in advance.