PC Review


Reply
Thread Tools Rate Thread

Display an hyperlink column in gridview using TemplateField

 
 
Valli
Guest
Posts: n/a
 
      27th Sep 2007
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJhdWxpbyBEaWV6?=
Guest
Posts: n/a
 
      27th Sep 2007
If you are using a DataSource, you don't need to use Eval

<asp:HyperLinkField HeaderText="Title"
DataNavigateURLFields="GridNavigationURL" DataTextField="Title"
SortExpression="Title">
<HeaderStyle Width="250px" />
</asp:HyperLinkField>

I use it in this way (GridNavigationURL and Title are column from the
Datasource)

HTH
Braulio


/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------




"Valli" wrote:

> 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
>
>
>

 
Reply With Quote
 
Valli
Guest
Posts: n/a
 
      27th Sep 2007
Hi,

Thanks for your help.
If I use this, the field is not getting displayed with the values & also i
couldnt see there any hyperlink way (ie no hand cursor on that column)

Can you help me..

--
Regards
Valli
"Braulio Diez" <(E-Mail Removed)> wrote in message
news:FCB9F50E-4DA1-4606-BE9E-(E-Mail Removed)...
> If you are using a DataSource, you don't need to use Eval
>
> <asp:HyperLinkField HeaderText="Title"
> DataNavigateURLFields="GridNavigationURL" DataTextField="Title"
> SortExpression="Title">
> <HeaderStyle Width="250px" />
> </asp:HyperLinkField>
>
> I use it in this way (GridNavigationURL and Title are column from the
> Datasource)
>
> HTH
> Braulio
>
>
> /// ------------------------------
> /// Braulio Diez
> ///
> /// http://www.tipsdotnet.com
> /// ------------------------------
>
>
>
>
> "Valli" wrote:
>
>> 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
>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?QW5kcmV3IEhheWVz?=
Guest
Posts: n/a
 
      28th Sep 2007
<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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView and TemplateField Help Jonathan Wood Microsoft ASP .NET 4 1st May 2008 09:07 PM
gridview column values to another page via gridview hyperlink column Keith G Hicks Microsoft ASP .NET 3 18th Feb 2008 06:17 AM
Help with Gridview and templatefield column Rafia Tapia Microsoft ASP .NET 1 29th Jul 2007 05:44 AM
Re: TemplateField in Gridview Eliyahu Goldin Microsoft ASP .NET 0 19th Dec 2006 08:40 AM
Gridview control and sorting a calculated templatefield column ? markm75c@msn.com Microsoft ASP .NET 2 14th Jun 2006 02:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.