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.
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;
}
}