Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. <%#Container.DataItem(" ")%> problem

<%#Container.DataItem(" ")%> problem

Scheduled Pinned Locked Moved ASP.NET
helpquestionhtmldocker
5 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beastyboy
    wrote on last edited by
    #1

    Hi all, in my html-code I have the following line: This line works fine, BUT than I have to put my images in the root of my project. In my situation all the images are in the /images-directory How do I have to modify my ImageUrl-tag to get this right? I already tried: ')" /> but he didn't find the image, I only got a box with the red cross does anybody can help me? Thank you very much respect 2B respected

    M J G B 4 Replies Last reply
    0
    • B beastyboy

      Hi all, in my html-code I have the following line: This line works fine, BUT than I have to put my images in the root of my project. In my situation all the images are in the /images-directory How do I have to modify my ImageUrl-tag to get this right? I already tried: ')" /> but he didn't find the image, I only got a box with the red cross does anybody can help me? Thank you very much respect 2B respected

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, You simply edit the data binding expression like this:

      ImageUrl='<%# DataBinder.Eval(Container.DataItem, "picname", "images/{0}")%>'

      The Server.MapPath() method returns the physical path that corresponds to a virtual url, so it does not help here. For more information, see Data Binding Expression Syntax [^]

      1 Reply Last reply
      0
      • B beastyboy

        Hi all, in my html-code I have the following line: This line works fine, BUT than I have to put my images in the root of my project. In my situation all the images are in the /images-directory How do I have to modify my ImageUrl-tag to get this right? I already tried: ')" /> but he didn't find the image, I only got a box with the red cross does anybody can help me? Thank you very much respect 2B respected

        J Offline
        J Offline
        jitendrapatel
        wrote on last edited by
        #3

        Hi Friend use this code hope u will solve ur problem ImageUrl='images/<%# Container.DataItem("picname") %>' Jitendra J. A. Patel

        1 Reply Last reply
        0
        • B beastyboy

          Hi all, in my html-code I have the following line: This line works fine, BUT than I have to put my images in the root of my project. In my situation all the images are in the /images-directory How do I have to modify my ImageUrl-tag to get this right? I already tried: ')" /> but he didn't find the image, I only got a box with the red cross does anybody can help me? Thank you very much respect 2B respected

          G Offline
          G Offline
          gnjunge
          wrote on last edited by
          #4

          You can also use" In VB.NET ImageUrl='<%#Server.MapPath('images/' & Container.DataItem("picname"))%>' /> In C# you have to use the + in stead of the &. And you might have to convert the container dataitem to a string.

          1 Reply Last reply
          0
          • B beastyboy

            Hi all, in my html-code I have the following line: This line works fine, BUT than I have to put my images in the root of my project. In my situation all the images are in the /images-directory How do I have to modify my ImageUrl-tag to get this right? I already tried: ')" /> but he didn't find the image, I only got a box with the red cross does anybody can help me? Thank you very much respect 2B respected

            B Offline
            B Offline
            beastyboy
            wrote on last edited by
            #5

            Hey, thank you all for your posts.. I found a solution in this: ImageUrl='<%# "~\images\" + CStr(DataBinder.Eval(Container.DataItem,"AntwFig")) %>' /> respect 2B respected

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups