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

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:

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