Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ImageURL setting

Reply
Thread Tools

ImageURL setting

 
 
pvong
Guest
Posts: n/a
 
      12-11-2008
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:
------------------------------------
Dim pix As Image = CType(e.Row.FindControl("StatusI"), Image)
pix.ImageUrl = "/Images/cryingface.gif"


 
Reply With Quote
 
 
 
 
pvong
Guest
Posts: n/a
 
      12-12-2008
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"


 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      12-12-2008
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




"pvong" <phillip*at*yahoo*dot*com> wrote in message
news:e%(E-Mail Removed)...
> 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"
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1.1: Setting ImageUrl of ImageButton does not work DC ASP .Net 2 07-30-2007 01:56 PM
ASP.NET 2.0, setting the ImageUrl value, how??? Jeff ASP .Net 0 02-21-2007 10:04 PM
setting an image control imageurl and displaying picture Aussie Rules ASP .Net 2 07-26-2006 07:49 PM
setting ImageUrl for images through code not working mich_stone@yahoo.com ASP .Net 2 12-09-2004 07:12 AM
Hyperlink w/ImageUrl bug? Leigh Kendall ASP .Net 8 08-19-2003 01:47 PM



Advertisments