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 oth开发者_JAVA百科er users will only be able to view.
how do customize the gridview so that only a specific user has the option to update?
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>";
精彩评论