Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 29th, 2008, 11:00 AM
Authorized User
 
Join Date: Jan 2008
Location: , , .
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>


###################
Reply With Quote
  #2 (permalink)  
Old February 29th, 2008, 05:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

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


Brian
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:56 PM.


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