Gridview update button

I have reviewed the discussion forum and attempted the solutions, however the update button fails to hide from my form. I have used the gridview form designer properties to remove the edit and delete buttons, but that results in my gridview being completely removed from the form during runtime. I have found previous discssions on the topic where code was provided inb order to hide buttons but that only seems to work after the gridview has been updated manually. I am populating and updating the gridview programmatically so there is no reason I need an update button on the form at all.

Hello.

Here’s what I’ve done (and it’s working).

The grid view is “standard” and not in read only mode :

No specific validation and no personalized parameters.

Here’s the code I’ve done :

// Init pour la bonne gestion des grilles
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    init_gridviews();
}     

// Init pour la bonne gestion des grilles ALV
protected override void OnPreLoad(EventArgs e)
{
    base.OnPreLoad(e);
    init_gridviews();
}     

// Gestion event des grilles
private void init_gridviews()
{   
    //Delete edit button from gridview
    NAME_OF_GRIDVIEW.RowDataBound                     += new GridViewRowEventHandler(Gridview_RowDataBound);

}

//Button mgt on grid view
private void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
    // You need to identify the column number of the buttons
    // In this example, my gridview has 3 columns. Buttons are in column number 4 (so index = 3)
    int index = 3;


    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        foreach (Control c in e.Row.Cells[index].Controls)
        {
            if (c is Button)
            {
                Button b = (Button)c;
                if (b.Text == "Edit" || b.Text == "Update" || b.Text == "Delete")
                {
                    b.Visible = false;
                }
            }
        }
    }
}          

I hope it helps.

Best regards