Link to home
Start Free TrialLog in
Avatar of mitdaniels
mitdaniels

asked on

GridView hyperlink image done another way?

Is there a another way of adding a hyperlinked image to a GridView:

<asp:GridView runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
    <ItemTemplate>
        <asp:HyperLink NavigateUrl='<%# Eval("HttpUri")%>' runat="server">
            <asp:image imageurl='<%# Eval("ImageUri")%>' runat="server" />
        </asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mitdaniels
mitdaniels

ASKER

Thanks, do you know whether these are the only 2 ways of doing this. In other words, do I have to use the TemplateField / ItemTemplate controls to achieve this?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried without the template field, but cannot get the image to display when it loads, instead it provides a link to the image. How do I get the image to display as soon as the control is loaded?

<asp:HyperLinkField DataNavigateUrlFields="ImageUri" DataTextField="LabName" NavigateUrl="HttpUri" />
Thanks