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

前端 未结 3 1885
悲哀的现实
悲哀的现实 2021-01-23 06:26

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

相关标签:
3条回答
  • 2021-01-23 06:31
    <asp:Repeater ID="RepeaterImages" runat="server">
        <ItemTemplate>
            <asp:Image ID="Image" runat="server" ImageUrl='<%# Container.DataItem %>' 
    Visible ='<%# Container.DataItem.ToString() == "0" ? true : false %>' />
        </ItemTemplate>
    </asp:Repeater>
    
    0 讨论(0)
  • 2021-01-23 06:43

    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 "";
              }
    
            }
    
    0 讨论(0)
  • 2021-01-23 06:51
    <asp:Repeater ID="RepeaterImages" runat="server">
        <ItemTemplate>
            <asp:Image ID="Image" runat="server" ImageUrl='<%# Container.DataItem %>' />
        </ItemTemplate>
    </asp:Repeater>
    
    0 讨论(0)
提交回复
热议问题