problem using Image control in DataList

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vitalii

    problem using Image control in DataList

    Hi

    I am using Image control with DataList control but have a problem. Here is the code I am using

    <asp:Image ImageURL='<%# DataBinder.Eval (Container.Data Item, "imagefilen ame" ) %>' Runat="Server" /

    I would like to change it to something like this

    <asp:Image ImageURL='image s/<%# DataBinder.Eval (Container.Data Item, "imagefilen ame" ) %>' Runat="Server" /

    In other words, I would like to add a folder name part to the ImageURL value. However it doesn't seem to work properly. What should I do

    Thank you in advance

    Vitalii
  • Joe Fallon

    #2
    Re: problem using Image control in DataList

    Try concatenating images/ with the Eval.

    Not sure if you just need

    &

    or

    &amp;
    --
    Joe Fallon



    "Vitalii" <vitaliid@gol.c om> wrote in message
    news:33128EA9-1CC3-4E1A-BEF0-6C8836D1F644@mi crosoft.com...[color=blue]
    > Hi,
    >
    > I am using Image control with DataList control but have a problem. Here is[/color]
    the code I am using:[color=blue]
    >
    > <asp:Image ImageURL='<%# DataBinder.Eval (Container.Data Item,[/color]
    "imagefilen ame" ) %>' Runat="Server" />[color=blue]
    >
    > I would like to change it to something like this:
    >
    > <asp:Image ImageURL='image s/<%# DataBinder.Eval (Container.Data Item,[/color]
    "imagefilen ame" ) %>' Runat="Server" />[color=blue]
    >
    > In other words, I would like to add a folder name part to the ImageURL[/color]
    value. However it doesn't seem to work properly. What should I do?[color=blue]
    >
    > Thank you in advance,
    >
    > Vitalii[/color]


    Comment

    • S. Justin Gengo

      #3
      Re: problem using Image control in DataList

      Vitalii

      Create a function in the code behind and call it from the databinding. It
      will look like this:

      '---Code behind function:
      Public Function GetImagePath(By Val imageFileName As String) As String
      Return "images/" & imageFileName
      End Function

      Then on the calling page call this function passing in the data:
      <asp:Image ImageURL='<%# GetImagePath(Da taBinder.Eval(C ontainer.DataIt em,
      "imagefilen ame" )) %>' Runat="Server" />

      --
      Sincerely,

      S. Justin Gengo, MCP
      Web Developer / Programmer



      "Out of chaos comes order."
      Nietzsche
      "Vitalii" <vitaliid@gol.c om> wrote in message
      news:33128EA9-1CC3-4E1A-BEF0-6C8836D1F644@mi crosoft.com...[color=blue]
      > Hi,
      >
      > I am using Image control with DataList control but have a problem. Here is[/color]
      the code I am using:[color=blue]
      >
      > <asp:Image ImageURL='<%# DataBinder.Eval (Container.Data Item,[/color]
      "imagefilen ame" ) %>' Runat="Server" />[color=blue]
      >
      > I would like to change it to something like this:
      >
      > <asp:Image ImageURL='image s/<%# DataBinder.Eval (Container.Data Item,[/color]
      "imagefilen ame" ) %>' Runat="Server" />[color=blue]
      >
      > In other words, I would like to add a folder name part to the ImageURL[/color]
      value. However it doesn't seem to work properly. What should I do?[color=blue]
      >
      > Thank you in advance,
      >
      > Vitalii[/color]


      Comment

      • mahsa

        #4
        RE: problem using Image control in DataList

        hi try this on
        <%#Server.MapPa th(@"\images"+D ataBinder.Eval( Container.DataI tem, "imagefilename" )%>

        Comment

        Working...