Wednesday, October 14, 2009

Hide Columns of GridView in Edit Mode

Hi,
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;
gridview.Columns.Add(colItemTemplate);

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)
{
gridview.DoRowValidation();

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



If you need more info leave a comment.


Njoy :)

No comments: