ImageURL setting

P

pvong

I'm trying to programmically set the location my image control. How do you
set it? The file is under an Image folder under the root directory of the
web folder.

I'm doing this in VB.NET and I'm trying to set this in RowDataBound. I'm
getting the error msg of: Object reference not set to an instance of an
object.

Below is my code:
 
P

pvong

Thanks for responding. I'm definitely a newbie. After getting your reply,
I realized how I could fix this but I'm not sure why it work. Below is my
code and it works fine. Can you tell me why I didn't have to use the Cell
count for this to work in my scenrio?
Dim pix As Image = CType(e.Row.FindControl("StatusI"), Image)

If e.Row.RowType = DataControlRowType.DataRow Then

pix.ImageUrl = "~\images\cryingface.gif"
 
S

S. Justin Gengo

Phillip,

Find control iterates through the row and the cells looking for the object
you specify. It can be very useful that it does so, but it's also an
intensive operation. Your applications will run faster if you limit your use
of find control and whenever possible refer to the objects you need directly
by giving the exact index of the object in question. Of course referring to
objects directly by figuring out their exact index is sometimes difficult.
And if you ever add a column you have to go into the code and re-index
everything which can be a pain.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top