Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid - Template or hyperlink Column?

Reply
Thread Tools

Datagrid - Template or hyperlink Column?

 
 
=?Utf-8?B?TG1jRQ==?=
Guest
Posts: n/a
 
      03-10-2005
Hi,

I have created a datagrid with a template column containing a datalist.
However, I need the text within the datalist to display as a hyperlink. Eack
of the links will point to another form with 2 parameters passed in.

Has anyone any ideas how to add the hyperlink?

Many Thanks


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJhZCBRdWlubg==?=
Guest
Posts: n/a
 
      03-10-2005
Template column;

<ItemTemplate>
<asp:HyperLink runat="server"
Text='<%# DataBinder.Eval(Container,"DataItem.TextField") %>'
NavigateUrl='<%# BuildUrl(
(int)DataBinder.Eval(Container,"DataItem.IntField" ),
(string)DataBinder.Eval(Container,"DataItem.String Field") ) %'>
</asp:HyperLink>
</ItemTemplate>

Code behind;

protected string BuildUrl( int field1, string field2 )
{
// TODO - Do whatever you need to do to build your Url
return string.Format( "{0}?field1={1}&field2={2}", baseUrl, field1, field2
);
}

"LmcE" wrote:

> Hi,
>
> I have created a datagrid with a template column containing a datalist.
> However, I need the text within the datalist to display as a hyperlink. Eack
> of the links will point to another form with 2 parameters passed in.
>
> Has anyone any ideas how to add the hyperlink?
>
> Many Thanks
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TG1jRQ==?=
Guest
Posts: n/a
 
      03-10-2005
Thats great - thanks

"Brad Quinn" wrote:

> Template column;
>
> <ItemTemplate>
> <asp:HyperLink runat="server"
> Text='<%# DataBinder.Eval(Container,"DataItem.TextField") %>'
> NavigateUrl='<%# BuildUrl(
> (int)DataBinder.Eval(Container,"DataItem.IntField" ),
> (string)DataBinder.Eval(Container,"DataItem.String Field") ) %'>
> </asp:HyperLink>
> </ItemTemplate>
>
> Code behind;
>
> protected string BuildUrl( int field1, string field2 )
> {
> // TODO - Do whatever you need to do to build your Url
> return string.Format( "{0}?field1={1}&field2={2}", baseUrl, field1, field2
> );
> }
>
> "LmcE" wrote:
>
> > Hi,
> >
> > I have created a datagrid with a template column containing a datalist.
> > However, I need the text within the datalist to display as a hyperlink. Eack
> > of the links will point to another form with 2 parameters passed in.
> >
> > Has anyone any ideas how to add the hyperlink?
> >
> > Many Thanks
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink davetichenor ASP .Net 1 10-30-2006 02:57 PM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink Dave ASP .Net Datagrid Control 0 10-21-2006 07:48 PM
Accessing a hyperlink in a template column in a Datagrid damonf ASP .Net 2 10-24-2003 04:02 PM
Dynamically Hyperlink and Event Handler for the Hyperlink ? Ken ASP .Net Datagrid Control 1 08-15-2003 11:38 PM
Re: A Newbie Question about template template template Chris Theis C++ 2 07-24-2003 09:42 AM



Advertisments