473,494 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic Hyperlink Column

I have a data grid with a hyperlink column. The hyperlink is created by a
class that extracts the link from an XML Document. How can I populate the
hyperlink column in the data grid with the value (link) returned from my
class method?

I have to send the company ticker to the class in order to get the correct
link. I tried embedding the method into the NavigateURL property of the data
grid (i.e. NavigateUrl="GetCompanyLink(Ticker)") but that didn't work.

Thanks.
Nov 19 '05 #1
2 2246
Jason:

Theres a few things you can do.

If you have a strongly typed dataset and generate it from within VS.NET,
you can specify the link value via the URL Field dropdown box in the
datagrid's properties window.

But if you prefer to do it at runtime, you can populate it using the
datagrid's ItemCreated event.

The following example assumes the hyperlink column is at the end of each
datagriditem row, and that the Hyperlink column contains only the
Hyperlink control. I am using the PhotoPath column from the Northwind
database, which is in the format "http://blahblahblah.bmp".

Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim lnkText As HyperLink =
CType(e.Item.Cells(e.Item.Cells.Count - 1).Controls(0), HyperLink)
lnkText.NavigateUrl = e.Item.DataItem("PhotoPath").ToString

End If
End Sub

Jason wrote:
I have a data grid with a hyperlink column. The hyperlink is created by a
class that extracts the link from an XML Document. How can I populate the
hyperlink column in the data grid with the value (link) returned from my
class method?

I have to send the company ticker to the class in order to get the correct
link. I tried embedding the method into the NavigateURL property of the data
grid (i.e. NavigateUrl="GetCompanyLink(Ticker)") but that didn't work.

Thanks.

Nov 19 '05 #2
I think I solved my own question. I used the ItemDataBound event to set the
table cell based on the company.

"Jason" wrote:
I have a data grid with a hyperlink column. The hyperlink is created by a
class that extracts the link from an XML Document. How can I populate the
hyperlink column in the data grid with the value (link) returned from my
class method?

I have to send the company ticker to the class in order to get the correct
link. I tried embedding the method into the NavigateURL property of the data
grid (i.e. NavigateUrl="GetCompanyLink(Ticker)") but that didn't work.

Thanks.

Nov 19 '05 #3

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

Similar topics

2
3130
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
2604
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...
2
2539
by: Dave Williamson | last post by:
When a ASPX page is created with dynamic controls based on what the user is doing the programmer must recreate the dynamic controls again on PostBack in the Page_Load so that it's events are wired...
9
15000
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 =...
10
1907
by: david | last post by:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign...
19
3463
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred...
3
3513
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
1
1186
by: Agnes | last post by:
I got a grid list the record, column1 is "number" When the user press colunn 1 , i want to show out the pdf file whose filename is same as column1's contents How can I do that ?? thanks a lot <a...
1
2021
by: mitramay | last post by:
I am creating a dynamic datagrid. The controls in some of the template columns will have to be generated based on the data contained in them (i.e. the data for that respective DataField column)....
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6873
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
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.