Could you give me an example? I am using the following code:
Private Sub datRatings_Item DataBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data ListItemEventAr gs) Handles
datRatings.Item DataBound
If CInt(CType(e.It em.DataItem, DataRowView)("t imesrated")) > 1 Then
If e.Item.ItemType = ListItemType.It em Then
CType(e.Item.Fi ndControl("lblT imesRated1"), Label).Text &= "s"
If e.Item.ItemType = ListItemType.Al ternatingItem Then
CType(e.Item.Fi ndControl("lblT imesRated2"), Label).Text &= "s"
End If
End Sub
And am recieving the following error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.
Source Error:
Line 140:
Line 141: Private Sub datRatings_Item DataBound(ByVal sender As
Object, ByVal e As System.Web.UI.W ebControls.Data ListItemEventAr gs) Handles
datRatings.Item DataBound
Line 142: If CInt(CType(e.It em.DataItem,
DataRowView)("t imesrated")) > 1 Then
Line 143: If e.Item.ItemType = ListItemType.It em Then
CType(e.Item.Fi ndControl("lblT imesRated1"), Label).Text &= "s"
Line 144: If e.Item.ItemType = ListItemType.Al ternatingItem
Then CType(e.Item.Fi ndControl("lblT imesRated2"), Label).Text &= "s"
Source File: C:\Inetpub\wwwr oot\poetry\poem ratings.aspx.vb Line: 142
Thanks.
--
Nathan Sokalski
nj********@hotm ail.com http://www.nathansokalski.com/
"Adam Knight" <ad**@pertrain. com.au> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Use the DataGridItems DataItem method.
It Returns a reference to the source data row as a DataRowView object.
Hope it helps.
Adam