DevExpress-Examples / asp-net-web-forms-grid-hide-edit-form-editor-programmatically

Hide an editor for a column based on certain conditions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grid View for ASP.NET Web Forms - How to hide the EditForm editor and column caption programmatically

In this example, the edit form hides an editor for the Description column if the current row's category name meets certain conditions.

GridView edit form

Implementation Details

Specify the EditFormSettings.Visible property value in the BeforeGetCallbackResult event handler to change an editor's visibility.

private string[] values = new string[] { "CategoryName1", "CategoryName3", "CategoryName5", "CategoryName7" };
//...
protected void gv_BeforeGetCallbackResult(object sender, EventArgs e) {
    HideEditor(sender as ASPxGridView);
}

private void HideEditor(ASPxGridView gv) {
    if (gv.IsEditing && !gv.IsNewRowEditing) {
        string value = gv.GetRowValues(gv.EditingRowVisibleIndex, "CategoryName").ToString();
        gv.DataColumns["Description"].EditFormSettings.Visible = values.Contains(value) ? DefaultBoolean.False : DefaultBoolean.True;
    }
}

Files to Look At

More Examples

About

Hide an editor for a column based on certain conditions.

License:Other


Languages

Language:Visual Basic .NET 35.1%Language:C# 34.3%Language:ASP.NET 30.6%