Gridview show edit button

Total Post:110

Points:776
 1335  View(s)
Ratings:
Rate this:

I’m having some issues with the edit button inside a gridview. When you click edit in the gridview, the cancel button gets the same css class as the edit button. So my cancel button gets the same edit icon.

I want to change this so that the cancel button gets a different css-class. So I can give it the right icon instead of an edit icon

<asp:CommandField ShowEditButton="True" ButtonType="Button" ControlStyle-CssClass="edit-sprite"></asp:CommandField>

  1. Post:378

    Points:2694
    Re: Gridview show edit button

    Hi Jeet, 

    You could use TemplateFields instead of CommandFields:

        
    <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                <asp:LinkButton ID="EditButton" runat="server"
                                CssClass="EditButton"
                                CommandName="Edit"
                                Text="Edit" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:LinkButton ID="UpdateButton"  runat="server"
                                CssClass="UpdateButton"
                                CommandName="Update"
                                Text="Update" />&nbsp;
                <asp:LinkButton ID="Cancel"
                                runat="server"
                                CssClass="CancelButton"
                                CommandName="Cancel"
                                Text="Cancel" />
            </EditItemTemplate>
           </asp:TemplateField>
           <asp:TemplateField>
             <ItemTemplate>
               <asp:LinkButton ID="DeleteButton"
      CssClass="DeleteButton"
                            Text="Delete"
                            CommandName="Delete"
                            runat="server" />
             </ItemTemplate>
         </asp:TemplateField>

      Modified On Apr-04-2018 06:38:52 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!