FindControl in DataListItem
Hi
I am trying to access the image control "ImgCelebrity". But keep getting the error message "
Object reference not set to an instance of an object." Please help me out...
My code is given bellow:
######################
Dim ImgCelebrity1 As Image = CType(DlstCategory.FindControl("ImgCelebrity"), Image)
ImgCelebrity1.Visible = False
#####################
<asp:DataList ID ="DlstCategory" runat ="server" RepeatDirection ="Horizontal" RepeatColumns = "2" Width="485px">
<HeaderTemplate >
<asp:Image ID ="ImgCelebrity" runat ="server" ImageUrl ="/images/Skins/title-latestnews.gif" />
</HeaderTemplate>
<ItemTemplate>
<img alt="" src="http://www.lookinggood-feelinggreat.co.uk/images/arrow_home.gif">
<a href='http://bdevweb01:5013/tabid/97/CategoryName/<%# Replace(Eval("CategoryName")," ","-") %>/default.aspx'> <%# Eval("CategoryName")%> </a>
</ItemTemplate>
<ItemStyle />
<HeaderStyle/>
</asp:DataList>
###################
|