Cool DataGrid Trick

Did you know that you can trick the DataGrid's ButtonColumn to use an image for a button without having to use a TemplateColumn? It's actually really easy. In the DataGrid Property Builder, change the column's Button Type to “LinkButton”, then use regular HTML for the “Text” property, like so:

<IMG src="/common/images/icons/16/delete.gif" border=0>

Click “Apply“, and presto! you now have an image button without the hassle of having a TemplateColumn. Switch over to the ASPX code view, and you should see the following:

<asp:ButtonColumn Text="&lt;img src=&quot;/common/images/icons/16/delete.gif&quot; border=&quot;0&quot; /&gt;" CommandName="Delete" />

Nifty, huh?

7 Comments

Comments have been disabled for this content.