image in datalist please help

Discussion in 'ASP .Net Datagrid Control' started by mahsa, May 1, 2004.

  1. mahsa

    mahsa Guest

    hi
    I have a datalist that show product and their image I us
    <asp:Image ImageUrl='<%#Server.MapPath(@"\images\roomscenes\"+DataBinder.Eval(Container.DataItem, "PartNo")+"_ss.jpg") %>' runat="server" ID="Image1" /
    but some times there is no image for one product and the page show me the asp image whitout any picture with a red
    i what if there is no picture for one product the datalist dont show any thing and dont show asp:image whitout picture ,do you have any ide
    mahsa, May 1, 2004
    #1
    1. Advertising

  2. mahsa

    David Jessee Guest

    Server.MapPath returns a file path to the image. If you look that the
    renderes html in you web page, you'll see that you end up with something
    like "c:\inetpub\wwwroot\images\roomscenes\3245_ss.jpg"
    you'll want to make sure that ou're returning a relative url to the image.

    Also if you do a MapPath of "\images" then it maps the path from your web
    root, as opposed to your web application's root (i.e. http://server/images
    versus http://server/MyApp/images)


    Side Note...
    you can use a tilde "~" in urls with asp.net apps to denote your
    appplication's root url, so you could use something like...

    <asp:Image ImageUrl='<%#
    "~\images\roomscenes\"+DataBinder.Eval(Container.DataItem,
    "PartNo")+"_ss.jpg") %>' runat="server" ID="Image1" />

    Assuming that "images" is a directory located inside your application (e.g.
    http://server/myapp/images)

    "mahsa" <> wrote in message
    news:D...
    > hi,
    > I have a datalist that show product and their image I use
    > <asp:Image

    ImageUrl='<%#Server.MapPath(@"\images\roomscenes\"+DataBinder.Eval(Container
    ..DataItem, "PartNo")+"_ss.jpg") %>' runat="server" ID="Image1" />
    > but some times there is no image for one product and the page show me the

    asp image whitout any picture with a red X
    > i what if there is no picture for one product the datalist dont show any

    thing and dont show asp:image whitout picture ,do you have any idea
    >
    David Jessee, May 1, 2004
    #2
    1. Advertising

  3. mahsa

    mahsa Guest

    hi I can use the code for show the image I have imajin i have 30 products that 28 of them have image but 2 of them dosent have when I try to show the image in datalist for 2 product that dont have image datalist show imagebutton whithout any image with redx I want to do something that if the product dont have image the datalist dosent show image button
    mahsa, May 1, 2004
    #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. =?Utf-8?B?bWFoc2E=?=

    image in datalist please helppppppppppp

    =?Utf-8?B?bWFoc2E=?=, May 1, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,658
    =?Utf-8?B?bWFoc2E=?=
    May 1, 2004
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,833
  3. Replies:
    4
    Views:
    484
    Chris Uppal
    May 5, 2005
  4. KK
    Replies:
    2
    Views:
    498
    Big Brian
    Oct 14, 2003
  5. MuZZy
    Replies:
    7
    Views:
    1,711
    Mike Hewson
    Jan 7, 2005
Loading...

Share This Page