I want a GridView with visible “Edit” button and hidden “Update” button and when enetring edit mode for a row toggle visibility, like this example in here (around the middle of the page, I think he does with AutoGenerateEditButton=”true”).
This are my grid buttons:
<asp:TemplateField ItemStyle-CssClass="campoCentrado">
<ItemTemplate>
<asp:ImageButton ID="btEditarGrid" ImageUrl="~/imagenes/edit.png" CommandName="Edit" OnClick="GridView_EditMode" runat="server" />
<asp:ImageButton ID="btGuardarGrid" ImageUrl="~/imagenes/guardar.png" CommandName="Update" Visible="false" runat="server" />
</ItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="btInsertarGrid" ImageUrl="~/imagenes/insertar.png" OnClick="GridView_Insert" runat="server" />
</FooterTemplate>
</asp:TemplateField>
And my RowEditingevent, which doesn’t work:
Private Sub gvCuestionarios_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvCuestionarios.RowEditing
If e.NewEditIndex >= 0 Then
Dim guardar As ImageButton = gvCuestionarios.Rows(e.NewEditIndex).FindControl("btGuardarGrid")
If Not guardar Is Nothing Then
guardar.Visible = True
End If
End If
End Sub
Thank you
In your TemplateField add an EditItemTemplate and place your update button inside of it. Once you’re in edit mode it doesn’t matter if you make a button visible or not in the ItemTemplate, it won’t be displayed. This is because you are in the EditItemTemplate and not the ItemTemplate.