GridView. Get value.

S

shapper

Hello,

I need to get the value of a Gridfiew field named "Channel" which is
the first column of the Gridview.

I want to use that value to build the ToolTip of an image. How can I do
this?

Here is my code:

Private Sub gvRSSChannels_RowDataBound(ByVal src As Object, ByVal e
As GridViewRowEventArgs) Handles gvRSSChannels.RowDataBound

' Bind row elements
If e.Row.RowType = DataControlRowType.DataRow Then

' Define row view
Dim rvRSSChannels As DataRowView = CType(e.Row.DataItem,
DataRowView)

' Define channel data column
Dim channel As String = rvRSSChannels("Channel").ToString

' Define cells collection
Dim tccRSSChannels As TableCellCollection = e.Row.Cells

' Define hfIcon hyperlink
Dim hfIcon As HyperLink =
CType(tccRSSChannels(tccRSSChannels.Count - 3).Controls(0), HyperLink)
hfIcon.ImageUrl =
Me.GetLocalResourceObject("hfIcon.ImageUrl").ToString()
hfIcon.ToolTip = Me.GetGlobalResourceObject("RSS", "{0}_Title")
' ******
End If

End Sub

See, where I have *****: "{0}_Title"
I thought {0} would work but it is not working.

Could somebody tell me why?

Thanks,
Miguel
 
J

Jon Paal

''' <summary>
''' This event is fired immediately after ItemCreated event if item
''' supports data binding.
''' Here we are accessing the Datagrid Items (rows) and changing the
''' Tooltip of first columns inside that row.
''' </summary>
Public Sub grid_OnItemDataBound(sender As Object, e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim webCtrl As WebControl = CType(e.Item.Cells(0), WebControl)
webCtrl.ToolTip = "Tooltip value"
End If
End Sub 'grid_OnItemDataBound
 
S

shapper

Hi,

But why not do this in RowDataBound?
If I set there my ImageUrl can't I access the value of column 0 and use
it to create the tooltip?

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top