Hi Jeff
Without seeing your entire onItemDataBound method I can't really point out your problem. But, the most common cause of the error message you're getting in your method is that you're casting from a control that isn't there. Now I know you'll tell me it is there - so here are possible reasons why: 1. You're not checking what row type it is. Remember that the onItemDataBound row by row through EVERY row in the datagrid - including the header and footer. So you first need to check if it's a header or footer, and only run your code if it isn't. 2. Your control is in a template column As with item 1, if your control is in the editItemTemplate, and you haven't specified only to run your code only if it is an editItem row, then it will throw an exception of every item row, cause as far as it's concerned the control isn't in there. I hope this helps Doug Wilson | Lead Applications Developer | iX Webhouse iX Headoffice | Umhlanga, South Africa | Mobile: +2783 6412944 Tel: +2731 5669250 | Fax: +2731 5669260 | Email: [EMAIL PROTECTED] _____ From: Jeffrey Idea [mailto:[EMAIL PROTECTED] Sent: 11 May 2004 10:50 AM To: [EMAIL PROTECTED] Subject: [AspNetAnyQuestionIsOk] HTML Image control in DataList Im using an HTML Image control in a DataList. The reason for this is that I need the control to run a javascript function and if im not mistaken, this cannot be done by using a server side ASP control. The simple task Im trying to do is at the ItemDataBound event of the DataList, the image control should become invisible. Here's the code: Dim arrU As HtmlImage = CType(e.Item.FindControl("imgUp"), HtmlImage) arrU.Visible = False I get a Null object exception. Apparently, the control could not be found even if the control exists. I've used similar code to manipulate ASP Labels that are also inside the DataList and it works. What's wrong with my casting operation? Can I use instead an ASP Image control and still be able to run a custom javascript function that is declared in my client script? Thanks for your advice. Jeff Yahoo! Groups Sponsor ADVERTISEMENT <http://rd.yahoo.com/SIG=129erthlm/M=295196.4901138.6071305.3001176/D=groups /S=1705006764:HM/EXP=1084351836/A=2128215/R=0/SIG=10se96mf6/*http:/companion .yahoo.com> click here <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S= :HM/A=2128215/rand=873858843> _____ Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED] e> * Your use of Yahoo! Groups is subject to the Yahoo! <http://docs.yahoo.com/info/terms/> Terms of Service. [Non-text portions of this message have been removed] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
