Home > DeveloperSection > Forums > Gridview show edit button
Jeet Verma
Jeet Verma

Total Post:110

Points:776
Posted on    August-23-2014 7:34 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 802  View(s)
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>



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-23-2014 8:49 AM

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>


Don't want to miss updates? Please click the below button!

Follow MindStick