473,383 Members | 1,739 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,383 software developers and data experts.

HyperLink Field Problem

Hello,

In my GridView I have a HyperLink Field where I set the
DataNavigateUrlFormaString

MyHyperLinkField.DataNavigateUrlFormatString =
"~\RSS.ashx?Channel={0}&Culture=" &
System.Threading.Thread.CurrentThread.CurrentCultu re.ToString()

I believe {0} retrieves the value of my datasource column with index 0.
That value is "News".

What I get when I copy the link when previewing the page is:

http://localhost:1717/JaquelineRoxoA...SS.ashx?c=News

The part "http://localhost:1717/JaquelineRoxoAtelier%202006a/" is the
web site url in my localhost but then I can't see the culture value and
everything else is strange.

In my GridView all the QueryStrings I am building look strange and
don't work.

Could somebody help me out?

Thanks,

Miguel

Oct 6 '06 #1
3 3027
{0} does not correspond to a particular field in the datatable. It is the
first item bound to the particular field in the Grid view. Open the designer
back up and bind at least one field to that column. That field will fill the
{0} in teh url string.

If you are in code behind, you can set the bound field, as well.

NOTE: The GridView auto binding should be turned off when you start binding
in this manner.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"shapper" <md*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,

In my GridView I have a HyperLink Field where I set the
DataNavigateUrlFormaString

MyHyperLinkField.DataNavigateUrlFormatString =
"~\RSS.ashx?Channel={0}&Culture=" &
System.Threading.Thread.CurrentThread.CurrentCultu re.ToString()

I believe {0} retrieves the value of my datasource column with index 0.
That value is "News".

What I get when I copy the link when previewing the page is:

http://localhost:1717/JaquelineRoxoA...SS.ashx?c=News

The part "http://localhost:1717/JaquelineRoxoAtelier%202006a/" is the
web site url in my localhost but then I can't see the culture value and
everything else is strange.

In my GridView all the QueryStrings I am building look strange and
don't work.

Could somebody help me out?

Thanks,

Miguel

Oct 6 '06 #2
Hi Gregory,

I tried to fix this but after many hours I am having the same problem
or getting new problems. I will post my complete code. Could you,
please, take a look and tell me what am I doing wrong? I added "******"
to the code lines which I think interfer with the QueryString.

The GridView is all defined at runtime.

Private Sub gvRSSChannels_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles gvRSSChannels.Init

' Define gvRSSChannels properties
With gvRSSChannels
.AutoGenerateColumns = False
.BorderStyle = BorderStyle.None
.DataSource = gvRSSChannels_DataSource()
.GridLines = GridLines.Horizontal
.ShowFooter = False
.ShowHeader = False
End With

' Create, define and add icon template field
Dim tfIcon As New TemplateField
tfIcon.ItemTemplate = New gvRSSChannelsTemplate(Me,
ListItemType.Item)
gvRSSChannels.Columns.Add(tfIcon)

' Create, define and add name bound field
Dim bfName As New BoundField
With bfName
.DataField = "Channel"
End With
gvRSSChannels.Columns.Add(bfName)

' Create, define and add url hyperlink field
Dim hfUrl As New HyperLinkField
With hfUrl
.DataTextFormatString =
"Me.GetLocalResourceObject(""String.{0}"").ToStrin g()"
.DataNavigateUrlFormatString = "~\RSS.ashx?Channel={0}&Culture="
& System.Threading.Thread.CurrentThread.CurrentCultu re.ToString()
End With
gvRSSChannels.Columns.Add(hfUrl)

End Sub

Private Sub gvRSSChannels_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles gvRSSChannels.Load

' Bind GridView to its data source
If Not IsPostBack Then
gvRSSChannels.DataBind()
End If

End Sub

----- Template CLASS ----

' rRSSChannelsTemplate
Public Class gvRSSChannelsTemplate
Implements ITemplate

' Define parent page
Private parent As RSS

' Define template type
Private type As ListItemType

' Create new template
Sub New(ByVal parentPage As RSS, ByVal templateType As
ListItemType)

' Define parent page
parent = parentPage

' Define template type
type = templateType

End Sub

' Define template
Sub InstantiateIn(ByVal container As Control) Implements
ITemplate.InstantiateIn

' Select template type
Select Case type

Case ListItemType.Header ' Header template

Case ListItemType.Item ' Item template

' Create item template controls
Dim rtrhlIcon As New RssToolkit.RssHyperLink

' Add item template controls handlers
AddHandler rtrhlIcon.DataBinding, AddressOf
rtrhlIcon_DataBinding

' Add item template controls to gvRSSChannels
container.Controls.Add(rtrhlIcon)

Case ListItemType.EditItem ' Edit Item
template

Case ListItemType.Footer ' Footer template

End Select
End Sub

' rtrhlIcon data binding and properties
Private Sub rtrhlIcon_DataBinding(ByVal sender As Object, ByVal e
As System.EventArgs)

' Define rtrhlIcon
Dim rtrhlIcon As RssToolkit.RssHyperLink
rtrhlIcon = CType(sender, RssToolkit.RssHyperLink)

' Define rtrhlIcon container
Dim container As GridViewRow
container = CType(rtrhlIcon.NamingContainer, GridViewRow)

' Define rtrhlIcon properties
With rtrhlIcon
.ChannelName = Me.parent.GetLocalResourceObject("String." &
DataBinder.Eval(container.DataItem, "Channel")).ToString()
.ImageUrl =
Me.parent.GetLocalResourceObject("rtrhlIcon.ImageU rl").ToString()
.IncludeUserName = "False"
.NavigateUrl = "~/RSS.ashx?Channel=" &
DataBinder.Eval(container.DataItem, "Channel") & _
"&Culture=" &
System.Threading.Thread.CurrentThread.CurrentCultu re.ToString())
.ToolTip = Me.parent.GetLocalResourceObject("String." &
DataBinder.Eval(container.DataItem, "Channel")).ToString()
End With

End Sub

End Class

Thank You Very Much,
Miguel

Cowboy (Gregory A. Beamer) wrote:
{0} does not correspond to a particular field in the datatable. It is the
first item bound to the particular field in the Grid view. Open the designer
back up and bind at least one field to that column. That field will fill the
{0} in teh url string.

If you are in code behind, you can set the bound field, as well.

NOTE: The GridView auto binding should be turned off when you start binding
in this manner.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"shapper" <md*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,

In my GridView I have a HyperLink Field where I set the
DataNavigateUrlFormaString

MyHyperLinkField.DataNavigateUrlFormatString =
"~\RSS.ashx?Channel={0}&Culture=" &
System.Threading.Thread.CurrentThread.CurrentCultu re.ToString()

I believe {0} retrieves the value of my datasource column with index 0.
That value is "News".

What I get when I copy the link when previewing the page is:

http://localhost:1717/JaquelineRoxoA...SS.ashx?c=News

The part "http://localhost:1717/JaquelineRoxoAtelier%202006a/" is the
web site url in my localhost but then I can't see the culture value and
everything else is strange.

In my GridView all the QueryStrings I am building look strange and
don't work.

Could somebody help me out?

Thanks,

Miguel
Oct 6 '06 #3
Hi Gregory,

I read what you wrote and I have my autobinding turned off.
I also tried to not use {0} but I am having some problems there.

I am working on this for hours and everything looks fine.
It's just that all the links show messed up.
The GridView is all defined at runtime.

Could you, please, take a look at my code and tell me what am I doing
wrong?
I point with "****" the code line which I think are giving me problems
with QueryStrings.

Private Sub gvRSSChannels_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles gvRSSChannels.Init

' Define gvRSSChannels properties
With gvRSSChannels
.AutoGenerateColumns = False
.BorderStyle = BorderStyle.None
.DataSource = gvRSSChannels_DataSource()
.GridLines = GridLines.Horizontal
.ShowFooter = False
.ShowHeader = False
End With

' Create, define and add icon template field
Dim tfIcon As New TemplateField
tfIcon.ItemTemplate = New gvRSSChannelsTemplate(Me,
ListItemType.Item)
gvRSSChannels.Columns.Add(tfIcon)

' Create, define and add name bound field
Dim bfName As New BoundField
With bfName
.DataField = "Channel"
End With
gvRSSChannels.Columns.Add(bfName)

' Create, define and add url hyperlink field
Dim hfUrl As New HyperLinkField
With hfUrl
.DataTextFormatString =
"Me.GetLocalResourceObject(""String.{0}"").ToStrin g()"
.DataNavigateUrlFormatString = "~\RSS.ashx?Channel={0}&Culture="
& System.Threading.Thread.CurrentThread.CurrentCultu re.ToString()
' ****
End With
gvRSSChannels.Columns.Add(hfUrl)

End Sub

Private Sub gvRSSChannels_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles gvRSSChannels.Load

' Bind GridView to its data source
If Not IsPostBack Then
gvRSSChannels.DataBind()
End If

End Sub

---- Template CLASS ----

' rRSSChannelsTemplate
Public Class gvRSSChannelsTemplate
Implements ITemplate

' Define parent page
Private parent As RSS

' Define template type
Private type As ListItemType

' Create new template
Sub New(ByVal parentPage As RSS, ByVal templateType As
ListItemType)

' Define parent page
parent = parentPage

' Define template type
type = templateType

End Sub

' Define template
Sub InstantiateIn(ByVal container As Control) Implements
ITemplate.InstantiateIn

' Select template type
Select Case type

Case ListItemType.Header ' Header template

Case ListItemType.Item ' Item template

' Create item template controls
Dim rtrhlIcon As New RssToolkit.RssHyperLink

' Add item template controls handlers
AddHandler rtrhlIcon.DataBinding, AddressOf
rtrhlIcon_DataBinding

' Add item template controls to gvRSSChannels
container.Controls.Add(rtrhlIcon)

Case ListItemType.EditItem ' Edit Item
template

Case ListItemType.Footer ' Footer template

End Select
End Sub

' rtrhlIcon data binding and properties
Private Sub rtrhlIcon_DataBinding(ByVal sender As Object, ByVal e
As System.EventArgs)

' Define rtrhlIcon
Dim rtrhlIcon As RssToolkit.RssHyperLink
rtrhlIcon = CType(sender, RssToolkit.RssHyperLink)

' Define rtrhlIcon container
Dim container As GridViewRow
container = CType(rtrhlIcon.NamingContainer, GridViewRow)

' Define rtrhlIcon properties
With rtrhlIcon
.ChannelName = Me.parent.GetLocalResourceObject("String." &
DataBinder.Eval(container.DataItem, "Channel")).ToString()
' ****
.ImageUrl =
Me.parent.GetLocalResourceObject("rtrhlIcon.ImageU rl").ToString()
.IncludeUserName = "False"
.NavigateUrl = "~/RSS.ashx?Channel=" &
DataBinder.Eval(container.DataItem, "Channel") & _
"&Culture=" &
System.Threading.Thread.CurrentThread.CurrentCultu re.ToString())
.ToolTip = Me.parent.GetLocalResourceObject("String." &
DataBinder.Eval(container.DataItem, "Channel")).ToString()
' ****
End With

End Sub

End Class

Thank You Very Much,
Miguel

Cowboy (Gregory A. Beamer) wrote:
{0} does not correspond to a particular field in the datatable. It is the
first item bound to the particular field in the Grid view. Open the designer
back up and bind at least one field to that column. That field will fill the
{0} in teh url string.

If you are in code behind, you can set the bound field, as well.

NOTE: The GridView auto binding should be turned off when you start binding
in this manner.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"shapper" <md*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,

In my GridView I have a HyperLink Field where I set the
DataNavigateUrlFormaString

MyHyperLinkField.DataNavigateUrlFormatString =
"~\RSS.ashx?Channel={0}&Culture=" &
System.Threading.Thread.CurrentThread.CurrentCultu re.ToString()

I believe {0} retrieves the value of my datasource column with index 0.
That value is "News".

What I get when I copy the link when previewing the page is:

http://localhost:1717/JaquelineRoxoA...SS.ashx?c=News

The part "http://localhost:1717/JaquelineRoxoAtelier%202006a/" is the
web site url in my localhost but then I can't see the culture value and
everything else is strange.

In my GridView all the QueryStrings I am building look strange and
don't work.

Could somebody help me out?

Thanks,

Miguel
Oct 6 '06 #4

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

Similar topics

7
by: Randell D. | last post by:
Folks, I am working on a contact db using PHP and MySQL. My results so far outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can...
4
by: Tero Partanen | last post by:
Hello! I'm writing about a rather peculiar problem I'm having with Access2000. I have a table in which I have created one hyperlink-type field. I have given the field a default value which is...
1
by: Marco Krechting | last post by:
Hi All, This is a response on my earlier posting about trapping the standard access error message when you click on a hyperlink field and the file cannot be found. I know now how to work on the...
1
by: Badboy36 | last post by:
Hello user from googlegroups, i made a microsoft access database with front and backend. i created the backend in microsoft access97. for the frontend i made two versions (one for microsoft...
4
by: Andreas Meffert | last post by:
Hello, How can I change the Type of a field in a table from Memo to hyperlink? I import a table from Oracle to Access 2003. After that, the field type of some hyperlink-fields is "Memo". How...
3
by: hermawih | last post by:
Please help . I want to load the contents of another rtf document by double-clicking the words . Chapter1.rtf Chapter2.rtf Chapter3.rtf ....
10
by: hecsan07 | last post by:
I am a novice programmer. I want to have a hyperlink that looks like so: www.mycoolsite.com?a=21132. On click I want to extract the query string and use it to query a table within a DB (SQL...
19
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...
5
LAD
by: LAD | last post by:
Using Access 2003 on Windows 2000. My Skill Level: Med Low (Some VBA, okay with Access) Form: Single View - based on Query of single Table to sort by field. Application: Dealers email 'contract...
1
NeoPa
by: NeoPa | last post by:
Error 7980: The HyperlinkAddress or HyperlinkSubAddress property is read-only for this hyperlink I'm struggling with some code to update Hyperlinks in my table. The field is defined as a...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.