Link to home
Create AccountLog in
Avatar of mugsey
mugseyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Equivalent to gridview rowediting event on the detailsview control

In the code snippet below it shows how to check for a user in role before allowing it to go into edit mode.

How can I do the same thing with a detailsview control.

The control is being populated via an object data source
protected void gridView1_RowEditing(object sender, GridViewEditEventArgs e)
 
{
 
    If (User.IsInRole("Admin"))
 
    {
 
        //Set the edit index to -1 to exite edit mode.
 
        gridView1.EditIndex = -1;
 
    }
 
    else
 
    {
 
        gridView1.EditIndex = e.NewEditIndex
 
    }
  }

Open in new window

Avatar of Velio
Velio
Flag of South Africa image

is the ItemUpdating event is not appropriate, you can always do it in the ItemCommand event, checking for e.CommandName == "Edit"
Avatar of mugsey

ASKER

Could you give me a working example please?
ASKER CERTIFIED SOLUTION
Avatar of Velio
Velio
Flag of South Africa image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account