---
title: "Change AutoGeneratedDelete LinkButton of Gridview to an Image Button"  
description: "Change AutoGeneratedDelete LinkButton of Gridview to an Image Button"  
author: "Anonymous User"  
published: 2014-12-11  
updated: 2014-12-12  
canonical: https://www.mindstick.com/forum/12788/change-autogenerateddelete-linkbutton-of-gridview-to-an-image-button  
category: "asp.net"  
tags: ["c#", "gridview"]  
reading_time: 1 minute  

---

# Change AutoGeneratedDelete LinkButton of Gridview to an Image Button

i have a [gridview](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net) with AutoGenerateDeleteButton [Property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) set true. Of course this property [auto](https://www.mindstick.com/forum/33810/remote-view-in-android-auto-cancel-custom-notification) generates a [linkbutton](https://www.mindstick.com/forum/2100/linkbutton-to-expand-gridview-causes-row-colors-from-function-to-be-lost) at the leftmost of the gridview, my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) is, how can i change it to an [Image Button](https://www.mindstick.com/forum/12796/disable-postback-on-image-button-click-asp)?? i wanted my gridview to look more presentable by making the [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) buttons an image.

Thanks!

## Replies

### Reply by Jayden Bell

You can create a TemplateField and use autogeneratecolumns="false".

Here's an example of a GridView:

```
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false">    <Columns>        <asp:TemplateField>        <ItemTemplate>            <asp:LinkButton ID="Link" runat="server" Text="click" OnClick="link_Click"/>        </ItemTemplate>        </asp:TemplateField>        <asp:BoundField DataField="field1" HeaderText="My Column 1" />        <asp:BoundField DataField="field2" HeaderText="My Column 2" />     </Columns></asp:GridView>
```

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}
```

### Reply by Anonymous User

Try this

```
<Columns>  
<asp:CommandField ButtonType="Image"
DeleteImageUrl="~/Images/DeleteImage.png"     
ShowDeleteButton="true"/></Columns>
```

And set AutoGenerateDeleteButton="false"


---

Original Source: https://www.mindstick.com/forum/12788/change-autogenerateddelete-linkbutton-of-gridview-to-an-image-button

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
