It might not be the correct item type because of header templates etc., e.g.
(C#):
if( e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
// FindControl code here
}
--
Site:
www.eggheadcafe.com
UnBlog: petesbloggerama.blogspot.com
Metafinder:
www.blogmetafinder.com
"Nathan Sokalski" wrote:
> I am attempting to get the data that was bound to an item in a Repeater
> control for use in the ItemDataBound event. Here is the code I am using to
> attempt to retrieve the data:
>
> CType(e.Item.DataItem, DataRowView)("fieldname")
>
> This has normally worked for me in the past, but once in a while it gives me
> a problem for reasons I cannot understand. The error I am recieving is:
>
> Object reference not set to an instance of an object.
>
> I know that the datatable that I am binding to the Repeater has data in it,
> because the data is displayed on the page if I comment out this line of the
> code. Does anybody have any idea what I am doing wrong? Thanks.
>
>