ImageURL setting

Discussion in 'ASP .Net' started by pvong, Dec 11, 2008.

  1. pvong

    pvong Guest

    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"
    pvong, Dec 11, 2008
    #1
    1. Advertising

  2. pvong

    pvong Guest

    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"
    pvong, Dec 12, 2008
    #2
    1. Advertising

  3. 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%...
    > 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. Justin Gengo, Dec 12, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leigh Kendall

    Hyperlink w/ImageUrl bug?

    Leigh Kendall, Jul 29, 2003, in forum: ASP .Net
    Replies:
    8
    Views:
    482
    John Soulis [MSFT]
    Aug 19, 2003
  2. Replies:
    2
    Views:
    5,977
    aa7im
    Dec 9, 2004
  3. Aussie Rules
    Replies:
    2
    Views:
    653
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 26, 2006
  4. Jeff
    Replies:
    0
    Views:
    905
  5. DC
    Replies:
    2
    Views:
    996
Loading...

Share This Page