开发者

allowing to update gridview depending on user authentication asp.net

开发者 https://www.devze.com 2023-03-29 15:21 出处:网络
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.

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>";
0

精彩评论

暂无评论...
验证码 换一张
取 消