Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 29th, 2008, 11:00 AM
Authorized User
 
Join Date: Jan 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>


###################
 
Old February 29th, 2008, 05:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Try this: CType(DlstCategory.Items(0).FindControl("ImgCelebr ity"), Image)


Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
using FindControl after ChangeMode in a FormView pbb ASP.NET 2.0 Basics 1 March 6th, 2007 10:11 AM
PreviousPage.FindControl returns nothing dschips BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 3 March 6th, 2007 08:35 AM
FindControl Wervis C# 7 November 30th, 2005 09:51 AM
FindControl dkr72 Excel VBA 0 January 19th, 2005 09:55 AM
Problem with FindControl RussC Excel VBA 1 June 16th, 2004 11:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.