'onRow function in asp.net based on role

would like to ask. Is it possible to check user's role in the onRow function. For example when user click on edit button (refer picture) then the system will the check their role first. if it is admin, they can edit the row (project name and description). if not admin then system will show sweet alert saying unauthorised user. Currently what I have is all user can click on edit button and make changes in the name and description as I use onRowEditing and onRowUpdating. enter image description here



Solution 1:[1]

Create a Method like this.

protected void StudentsGrid_RowEditing(object sender, GridViewEditEventArgs e)
{
   if(User.IsInRole("Admin"))
   {
    // Admin Code
   }       
   else if(User.IsInRole("User"))
   {
    ///User Code
   }
   else
   {
    //Default Part
   }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 M Rizwan