aspnet-devexpress-dot-web-dot-aspxgridview-7f7f9e11.md
Indicates whether a new row is being edited.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public bool IsNewRowEditing { get; }
Public ReadOnly Property IsNewRowEditing As Boolean
| Type | Description |
|---|---|
| Boolean |
true if a new row is being edited; otherwise, false.
|
The following example illustrates how to use the IsNewRowEditing property.
Web Forms approach:
protected void grid_StartRowEditing(object sender,
DevExpress.Web.Data.ASPxStartRowEditingEventArgs e) {
if (!grid.IsNewRowEditing)
grid.DoRowValidation();
}
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:
...
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.
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
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
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
protected void ASPxGridView1_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridViewEditorEventArgs e) {
if(ASPxGridView1.IsNewRowEditing && e.Column.FieldName == "CustomerID")
e.Editor.ReadOnly = false;
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
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
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
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