aspnet-devexpress-dot-web-dot-aspxgridview-e413d27b.md
Enables you to prevent a row from being edited.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event ASPxStartRowEditingEventHandler StartRowEditing
Public Event StartRowEditing As ASPxStartRowEditingEventHandler
The StartRowEditing event's data class is ASPxStartRowEditingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| EditingKeyValue | Gets the processed row’s key value. |
The StartRowEditing event occurs when an end-user has clicked the Edit command or the ASPxGridView.StartEdit method has been called. To prevent switching the ASPxGridView to edit mode, set the event parameter’s Cancel property to true.
The code sample below demonstrates how you can prohibit a user from editing data rows containing information unrelated to the Sales department.
string UserDepartment = "Sales";
...
protected void MyGridView_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e) {
if (MyGridView.GetRowValuesByKeyValue(e.EditingKeyValue, "Department").ToString() != UserDepartment) {
e.Cancel = true;
}
}
Dim UserDepartment As String = "Sales"
...
Protected Sub MyGridView_StartRowEditing(sender As Object, e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs)
If MyGridView.GetRowValuesByKeyValue(e.EditingKeyValue, "Department").ToString() <> UserDepartment Then
e.Cancel = True
End If
End Sub
<dx:ASPxGridView ID="MyGridView" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource1"
KeyFieldName="ID" OnStartRowEditing="MyGridView_StartRowEditing">
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0">
<EditButton Visible="True">
</EditButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="Department" ReadOnly="True" VisibleIndex="0">
</dx:GridViewDataTextColumn>
...
</Columns>
</dx:ASPxGridView>
See Also