如何在asp.net的转发器控件列中显示图像?

Pri*_*nka 2 html c# asp.net repeater

我正在使用asp.net的转发器控件进行数据绑定.而对于设计我使用div和span进行数据表示.我的桌子有4个字段,我想根据字段值显示每个跨度上的图像.图像存储在我的项目路径中.

这该怎么做?

Pra*_*nth 6

用这个

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

现在我们需要创建一个函数来使用该ID检索图像.

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

        }
Run Code Online (Sandbox Code Playgroud)