Home > DeveloperSection > Forums > Change AutoGeneratedDelete LinkButton of Gridview to an Image Button
Brad Pitt
Brad Pitt

Total Post:61

Posted on    December-11-2014 10:35 PM

 ASP.Net C#  Gridview 

 2 Reply(s)
 3852  View(s)
Rate this:

i have a gridview with AutoGenerateDeleteButton Property set true. Of course this property auto generates a linkbutton at the leftmost of the gridview, my question is, how can i change it to an Image Button?? i wanted my gridview to look more presentable by making the control buttons an image.


Simons Hood
Simons Hood

Total Post:70

Posted on    December-12-2014 6:10 AM

Try this



   <asp:CommandField ButtonType="Image" DeleteImageUrl="~/Images/DeleteImage.png"



And set AutoGenerateDeleteButton="false"

Jayden Bell
Jayden Bell

Total Post:105

Posted on    December-12-2014 6:54 AM

You can create a TemplateField and use  autogeneratecolumns="false".


Here's an example of a GridView:


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false">




            <asp:LinkButton ID="Link" runat="server" Text="click" OnClick="link_Click"/>



        <asp:BoundField DataField="field1" HeaderText="My Column 1" />

        <asp:BoundField DataField="field2" HeaderText="My Column 2" />



Where field1 and field2 are headers from your DataTable


And to access the row within the event handler:


protected void link_Click(object sender, EventArgs e)


    int rowindex = ((GridViewRow)((Control)sender).NamingContainer).RowIndex;

    //do something with rowindex etc


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

Follow MindStick