GridView.EditIndex Property

Gets or sets the index of the row to edit.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public:
virtual property int EditIndex {
	int get ();
	void set (int value);
}
/** @property */
public int get_EditIndex ()

/** @property */
public void set_EditIndex (int value)

public function get EditIndex () : int

public function set EditIndex (value : int)

Not applicable.

Property Value

The zero-based index of the row to edit. The default is -1, which indicates that no row is being edited.

Exception typeCondition

ArgumentOutOfRangeException

The specified index is less than -1.

Use the EditIndex property to programmatically specify or determine which row in a GridView control to edit. When this property is set to the index of a row in the control, that row enters edit mode. In edit mode, each column field in the row that is not read-only displays the appropriate input control for the field's data type, such as a TextBox control. This allows the user to modify the field's value. To exit edit mode, set this property to -1.

NoteNote:

The GridView control has a built-in editing feature that automatically sets this property. This property is typically used only when you need to programmatically determine which row is being edited or when you are adding your own custom editing functionality to the GridView control.

The following code example demonstrates how to use the EditIndex property to determine which row is being edited in a GridView control. After a row is updated, a message is displayed to indicate that the update was successful.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: