how to show image in the column of repeater control in asp.net?

17,645

Use this

<asp:Repeater ID="RepeaterImages" runat="server">
    <ItemTemplate>
        <img src='<%#GetImage(Databinder.Eval(Container.DataItem, "ImageID"))%>' alt="" width="" height="" />
    </ItemTemplate>
</asp:Repeater>

Now we need to create a function to retrieve the image using that ID.

public string GetImage(object ImadeID)
        {
          if(ImageID!=null)
            {
               //do something with the ImageID to return the image path as string
            }
          else
           {
           return "";
          }

        }
Share:
17,645
Priyanka
Author by

Priyanka

I'd completed my graduation in B.Sc.(Computer Science) &amp; Completed my post graduation in MCA. From last 6 months i'm working as a .NET software engineer in GS. I'm C# programmer. Right now i'm working on one project named MsgBlaster 4.0 which will be another version of earlier software MsgBlaster 3.0 which is message sending s/w from PC to mobile. It not required any mobile device or SMS modem connectivity with PC. And i like to use Stackoverflow when i stuck with any problem related to my project &amp; it helps me a lot... thanks.

Updated on July 21, 2022

Comments

  • Priyanka
    Priyanka almost 2 years

    I'm using repeater control from asp.net for data binding. And for designing i used the div & span for data representation. I have 4 fields to my table & i want to show the images on the each span depending on the field value. Images are stored in my project path itself.

    How to do this?