Home > Mobile >  onRow function in asp.net based on role
onRow function in asp.net based on role

Time:04-11

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

CodePudding user response:

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
   }
}
  • Related