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