itemDataBound and Editing the text

D

Dhruv

Hi,

I have a question

I have a grid

it is spitting this out

description
-----------
test1
test2
test3

I want to change it so that on ItemDataBound each row/value of
description column runs through a string function I pass it.

How do I do that?

here is my code so far:

Private Sub grdReadingNews_ItemDataBound(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
grdReadingNews.ItemDataBound
' below determines the column of the row that one should check
for (dataRowView)
'cint(e.item.itemIndex) is the actual row that it is on
**ITEM** property
'itemdatabound event is automatically looping through the grid
Dim objRow As DataRowView = CType(e.Item.DataItem,
DataRowView)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim startDate As String = objRow("StartDate")
Dim endDate As String = objRow("EndDate")
Dim description As boolean= objRow("description")
If endDate.IndexOf("1/1/1900") >= 0 Then
e.Item.Cells(5).Text = ""
End If
If startDate.IndexOf("1/1/1900") >= 0 Then
e.Item.Cells(4).Text = ""
End If
' I AM STUCK HERE, I WANT THE HTMLNEWLINE FUNCTION TO RUN
THROUGH EACH ROW OF THE DESCRIPTION COLUMN.
'If description.TrueString Then
' Me.sqlStmts.HTMLEncodeNewLine(e.Item.Cells(2).Text)
'End If
End If
End Sub


Here are some of the errors I'm getting:
Cast from string " Banner Health selected Learnsof" to type 'Boolean'
is not valid.
 
D

Dhruv

Hi Alvin,

I dont think you understand:

Here is my HTMLNewLineFunction:

Function HTMLEncodeNewLine(ByVal strData)
' THIS TAKES A STRING AND MANIPULATES IT AND SPITS OUT THE RESULT
return strData
End Function


Private Sub grdReadingNews_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
grdReadingNews.ItemDataBound

Dim objRow As DataRowView = CType(e.Item.DataItem, DataRowView)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
' e.Item.Cells(2) IS THE DESCRIPTION FIELD
Dim description As String = objRow("description")
e.Item.Cells(2).Text = Me.sqlStmts.HTMLEncodeNewLine
End If
End Sub

HOW DO I PASS EACH VALUE OF THE DESCRIPTION COLUMN TO THE HTMLNEWLINE
FUNCTION AS IT ITERATES DURING THE ITEM DATA BOUND FUNCTION???

Thanks

:D



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

Dhruv

I found the answer:

Dim description As String = objRow("description")


If description <> "" Then
e.Item.Cells(2).Text =
Me.sqlStmts.HTMLEncodeNewLine(e.Item.Cells(2).Text)
End If

:D
 

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

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top