Referencing Controls on ItemTemplate in FormView Control

M

mike

in the Page_Load event the following code works at design time but
does not work when placed on the production server.

I get an error "Object reference not set to an instance of an object."

the snippet is:

Image img = new Image();
img = FormView1.Row.FindControl("ProdPhoto") as Image;
if (img.ImageUrl.Length < 20)
img.ImageUrl = "images/unavailable.jpg";

This is on a standard Webform without master page.

I've been scouring the net trying to find the resolution for this but
have not had any luck although I've tried several suggestions.

I've read in many places that the ItemTemplate should be the
default....this is the only template I am using currently in this
FormView control so I can't figure out why FindControl is not locating
the image.
 
M

mike

David,

Thanks for the reply. I am only using the ItemTemplate in the
formview....I have it set for DefaultMode=ReadOnly. What gets me is
that it runs fine in design mode but not on the production server.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top