Alex Gordon
Alex Gordon

Reputation: 60711

allowing to update gridview depending on user authentication asp.net

i have a web app in asp.net running on windows authentication

i want only a specific user to be able to update, while the other users will only be able to view.

how do customize the gridview so that only a specific user has the option to update?

Upvotes: 1

Views: 614

Answers (1)

James Johnson
James Johnson

Reputation: 46047

After the GridView is bound, try adding this code somewhere:

CommandField editButton = GridView.Columns.OfType<CommandField>().ElementAtOrDefault(0);
if (editButton != null)
    editButton.Visible = HttpContext.Current.user.Identity.Name == "<USER NAME>";

Upvotes: 1

Related Questions