Wednesday, October 14, 2009

Hide Columns of GridView in Edit Mode

We had a requirement to Hide the columns of Grid in Edit form.And for that i have used EditFormSettings of the GridViewDataColumn.Pls find below code snippet.

Note: Below Solution/code is for DevExpress Controls FYI.

Gridviewcommand column creation.
Gridviewcommand column creation.
GridViewCommandColumn colItemTemplate = new GridViewCommandColumn();
colItemTemplate.NewButton.Visible = true;
colItemTemplate.EditButton.Visible = true;

Creating Event
gridview.StartRowEditing+=new DevExpress.Web.Data.ASPxStartRowEditingEventHandler(gridview_StartRowEditing);

private void gridview_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
if (!gridview.IsNewRowEditing)

((GridViewDataColumn)gridview.Columns[2]).EditFormSettings.Visible = DevExpress.Web.ASPxClasses.DefaultBoolean.False;

If you need more info leave a comment.

Njoy :)

No comments: