# Form designer: How to hide the update, edit, and delete buttons when a Gridview is ReadOnly

**URL:** https://discuss.workflowgen.com/t/form-designer-how-to-hide-the-update-edit-and-delete-buttons-when-a-gridview-is-readonly/280
**Category:** Form Designer
**Created:** [January 9, 2015, 4:01am UTC](https://discuss.workflowgen.com/t/form-designer-how-to-hide-the-update-edit-and-delete-buttons-when-a-gridview-is-readonly/280 "2015-01-09T04:01:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)
#### Post date: [January 9, 2015, 4:01am UTC](https://discuss.workflowgen.com/t/form-designer-how-to-hide-the-update-edit-and-delete-buttons-when-a-gridview-is-readonly/280/1 "2015-01-09T04:01:56Z")

</div>

Button visibility must be changed in the `Page_PreRenderComplete` event of the page because it is only at this moment that form field conditional validation rules are applied (ReadOnly, Required, Hidden). You must call `base.PreRenderComplete` at the beginning of the event to ensure the rules are set before the custom code.

To do this, add the following code to the .NET code of your form:

```auto
// Change REQUEST_GRIDVIEW1 to the ID of your Gridview
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
    base.Page_PreRenderComplete(sender, e);

    foreach (DataControlField field in REQUEST_GRIDVIEW1.Columns)
    {
        if (field is CommandField)
        {
            field.Visible = REQUEST_GRIDVIEW1.Enabled;
        }
    }
}

```
