Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to get image from data base using Reapeater in asp.net
Posted
Updated 2-Oct-17 21:26pm

in addition to the above links,these may help you
Bind Image With Repeater Control[^]
how to display image and data in Repeater Control [^]
 
Share this answer
 
ImageRepeater.aspx

C#
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:ConnectionString2 %>" xmlns:asp="#unknown">
            SelectCommand="SELECT * FROM [country]"></asp:sqldatasource>
        <asp:repeater id="Repeater1" runat="server" datasourceid="SqlDataSource1" onitemdatabound="Repeater1_ItemDataBound" xmlns:asp="#unknown">
         <itemtemplate>
             <asp:hiddenfield value="<%# Eval("id") %>" id="HiddenField1" runat="server" />
             <asp:image id="Image1" runat="server" />
         </itemtemplate>
        </asp:repeater>


ImageRepeater.aspx.cs

C#
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
   {
       HiddenField hf =  e.Item.FindControl("HiddenField1") as HiddenField;
       if (hf != null)
       {
           string val = hf.Value;
           Image img = e.Item.FindControl("Image1") as Image;
           img.ImageUrl = "~/image" + val + ".jpg";
       }



   }


reference.

how to display image and data in Repeater Control in asp.net & c sharp[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900