473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Datagrid - Template or hyperlink Column?

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
Nov 19 '05 #1
2 2218
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

Nov 19 '05 #2
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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bpschmid | last post by:
Ive got a datagrid with a hyperlink column. I want to click on that column and go to another page, but here's the kicker, I need and want to pass not one, but two different query string parameters...
4
by: | last post by:
I have a datagrid with a template column that has a hyperlink and a label. The hyperlink text is bound to Title from my dataset and the label text is bound to Author in the dataset. The grid...
2
by: Ravikanth[MVP] | last post by:
Hi asp:DataGrid id="YourID" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn HeaderText="Sample Column"> <ItemTemplate> <asp:Hyperlink runat="server" Text='<%...
2
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four...
0
by: MattB | last post by:
I got a response earlier, but I thought I'd bump this one to the top for a quick answer. Any tips, suggestions, or especially examples would be great! It seems like I may be able to do this...
2
by: Amir Eshterayeh | last post by:
Dear Friends I put a asp.net hyperlink control inside a datagrid as even a template column or hyperlink column but can not force datagrid to open a new window when I clicked on the hyperlink. I...
9
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring =...
1
by: Greg Reynolds | last post by:
Hi, I need to create datagrid hyperlink columns with multiple parameters in the URL. In my research on how to do this, it is recommended to create a template column which I have done. The code...
1
by: jeguillo | last post by:
I am trying to retrieve the text within each cell in a datagrid in order to change the color of each cell, depending on the value within that cell. This works fine on the cells that are bound...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.