Back to Devexpress

ASPxGridView.IsNewRowEditing Property

aspnet-devexpress-dot-web-dot-aspxgridview-7f7f9e11.md

latest6.6 KB
Original Source

ASPxGridView.IsNewRowEditing Property

Indicates whether a new row is being edited.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public bool IsNewRowEditing { get; }
vb
Public ReadOnly Property IsNewRowEditing As Boolean

Property Value

TypeDescription
Boolean

true if a new row is being edited; otherwise, false.

|

Remarks

The following example illustrates how to use the IsNewRowEditing property.

Web Forms approach:

csharp
protected void grid_StartRowEditing(object sender, 
DevExpress.Web.Data.ASPxStartRowEditingEventArgs e) {
    if (!grid.IsNewRowEditing)
        grid.DoRowValidation();
}
vb
Protected Sub grid_StartRowEditing(ByVal sender As Object,_
    ByVal e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs)
    If (Not grid.IsNewRowEditing) Then
        grid.DoRowValidation()
    End If
End Sub

MVC approach:

cshtml
...
settings.BeforeGetCallbackResult = (sender, e) => {
    MVCxGridView gridview = sender as MVCxGridView;
    if(gridview.IsNewRowEditing)
        gridview.DataColumns["Column_Name"].EditCellStyle.BackColor = System.Drawing.Color.Green;
    else        
        gridview.DataColumns["Column_Name"].EditCellStyle.BackColor = System.Drawing.Color.Yellow;                
};
...

View Example: How to use the Rich Text Editor to edit formatted text in the Edit Form

The following code snippets (auto-collected from DevExpress Examples) contain references to the IsNewRowEditing property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-grid-use-cascading-combo-boxes-in-inline-edit-mode/CS/MultiCombo/Default.aspx.cs#L44

csharp
if(!grid.IsNewRowEditing) {
    object[] vals = (object[])grid.GetRowValues(grid.EditingRowVisibleIndex,

asp-net-web-forms-grid-hide-edit-form-editor-programmatically/CS/Solution/Default.aspx.cs#L25

csharp
private void HideEditor(ASPxGridView gv) {
    if (gv.IsEditing && !gv.IsNewRowEditing) {
        string value = gv.GetRowValues(gv.EditingRowVisibleIndex, "CategoryName").ToString();

asp-net-web-forms-grid-editor-readonly-based-on-grid-state/CS/Solution/Default.aspx.cs#L9

csharp
if (e.Column.FieldName == "CategoryID")
        e.Editor.ReadOnly = !grid.IsNewRowEditing;
}

asp-net-web-forms-grid-editing-in-linq-server-mode/CS/WebSite/Default.aspx.cs#L15

csharp
protected void ASPxGridView1_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridViewEditorEventArgs e) {
    if(ASPxGridView1.IsNewRowEditing && e.Column.FieldName == "CustomerID")
        e.Editor.ReadOnly = false;

asp-net-web-forms-grid-use-cascading-combo-boxes-in-inline-edit-mode/VB/MultiCombo/Default.aspx.vb#L50

vb
If Not grid.IsNewRowEditing Then
    Dim vals() As Object = CType(grid.GetRowValues(grid.EditingRowVisibleIndex, New String() { "Category2ID", "Category3ID", "Category4ID" }), Object())

asp-net-web-forms-grid-hide-edit-form-editor-programmatically/VB/Solution/Default.aspx.vb#L24

vb
Private Sub HideEditor(ByVal gv As ASPxGridView)
    If gv.IsEditing AndAlso Not gv.IsNewRowEditing Then
        Dim value As String = gv.GetRowValues(gv.EditingRowVisibleIndex, "CategoryName").ToString()

asp-net-web-forms-grid-editor-readonly-based-on-grid-state/VB/Solution/Default.aspx.vb#L11

vb
Dim grid As ASPxGridView = TryCast(sender, ASPxGridView)
    If Equals(e.Column.FieldName, "CategoryID") Then e.Editor.ReadOnly = Not grid.IsNewRowEditing
End Sub

asp-net-web-forms-grid-editing-in-linq-server-mode/VB/WebSite/Default.aspx.vb#L14

vb
Protected Sub ASPxGridView1_CellEditorInitialize(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridViewEditorEventArgs)
    If ASPxGridView1.IsNewRowEditing AndAlso Equals(e.Column.FieldName, "CustomerID") Then e.Editor.ReadOnly = False
End Sub

See Also

ASPxGridView.AddNewRow

js-ASPxClientGridView.AddNewRow

InitNewRow

Grid View

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace