Reputation: 34038
I am creating a gridview and one of the columns should be a link, but instead of text I need an icon.
How can I accomplish that?
HyperLinkField bCSLink = new HyperLinkField();
bCSLink.NavigateUrl = "CsLink"; ??
grdiview.Columns.Add(bCSLink);
Upvotes: 0
Views: 352
Reputation: 6712
Use a template field.
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="myHyperLink" runat="server">
<asp:Image ID="imSomething" runat="server" SkinID="Something" />
<asp:Image ID="imSomethingElse" runat="server" SkinID="SomethingElse" />
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
Then make the image you want to display Visible and the other ones non Visible.
Upvotes: 0
Reputation: 8129
Just Set the Text your HyperLink like this.....
bCSLink .Text = @"<img src='"+ResolveUrl("Path of Image of Delete Icon")+"' /> ";
Upvotes: 1