System.Web.UI.WebControls.GridView.EditIndex Property

Gets or sets the index of the row to edit.

Syntax

[System.ComponentModel.DefaultValue(-1)]
public virtual int EditIndex { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

The row index is zero-based (the first row is row zero).

This property is typically used only in the following scenarios, which involve handlers for specific events:

If you set the GridView.EditIndex property after a postback or in handlers for events that are raised later than the System.Web.UI.Control.Load event, the System.Web.UI.WebControls.GridView control might not enter edit mode for the specified row. If you read the value of this property in other event handlers, the index is not guaranteed to reflect the row that is being edited.

To determine which row the user has clicked an Edit button or hyperlink in before the System.Web.UI.WebControls.GridView control enters edit mode, you can retrieve the row index from the GridViewEditEventArgs.NewEditIndex property of the System.Web.UI.WebControls.GridViewEditEventArgs object in the GridView.RowEditing event handler.

To prevent the System.Web.UI.WebControls.GridView control from entering edit mode after a user has clicked an Edit button or hyperlink, set the System.ComponentModel.CancelEventArgs.Cancel property of the System.Web.UI.WebControls.GridViewEditEventArgs object to true in the GridView.RowEditing event handler.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0