471,071 Members | 7,703 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Display an hyperlink column in gridview using TemplateField

Hi,

I need to display an hyperlink column in gridview where if the user
clicks that column the page should move to the selected page.
I have got help from this group & started using template field. After using
this, I couldnt see a column supporting hyperlink.
In the gridviews first column header, there appears an hyperlink with the
first record link displaying. That also only in header overwriting with the
first column caption.

can anyone help me in this..

My code follows here...

<asp:TemplateField>
<ItemTemplate>

<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#
Eval("FileLink") %>'

Style="z-index: 100; left: 0px; position: absolute; top: 0px" Text='<%#
Eval("FileLink") %>'></asp:HyperLink>

</ItemTemplate>
</asp:TemplateField>

--FileLink is the datafield name which provides the link
--
Thanks & Regards
Valli
Sep 27 '07 #1
1 6823
<asp:XmlDataSource ID="XmlDataSource1" runat="server">
<Data>
<Links>
<Link FileLink="http://www.microsoft.com"/>
<Link FileLink="http://msdn.microsoft.com"/>
<Link FileLink="http://technet.microsoft.com"/>
</Links>
</Data>
</asp:XmlDataSource>

is the source for

<asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1">
<Columns>
<asp:HyperLinkField
DataNavigateUrlFields="FileLink"
DataTextField="FileLink"/>
</Columns>
</asp:GridView>

and

<asp:GridView ID="GridView2" runat="server" DataSourceID="XmlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
Text='<%# Eval("FileLink") %>'
NavigateUrl='<%# Eval("FileLink") %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

We could help you, and others, better if you post more of your code rather
than just posting a TemplateField. At least then when someone copies and
pastes the code into a new ASPX page it'll produce a result.

Sep 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Wayne Wengert | last post: by
5 posts views Thread by Stephen | last post: by
3 posts views Thread by shapper | last post: by
3 posts views Thread by AG | last post: by
1 post views Thread by Martin.Coetsee | last post: by
3 posts views Thread by Uriah Piddle | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.