Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to display image and data in Repeater Control in asp.net & c sharp.
Please Send me a application urgent
Posted
Updated 2-Oct-17 21:17pm
v2

Here u have to maintain the image Folder which contains all the images and the Filename only taken from database
C#
<asp:Repeater ID="repeatimages" runat="server" >
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Name</th>
<th>Password</th>
<th>Images</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="lbl" runat="server" Text='<%#Eval("uname") %>'></asp:Label> </td>
<td><%#Eval("upass")%> </td>
<td>
<img  src="../image/<%# Eval("photo") %>" alt="" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>


In Code behind

C#
string query = "select * from Profiledetails";
SqlConnection con = new SqlConnection(conn);
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
da.Fill(ds);
repeatimages.DataSource = ds;
repeatimages.DataBind();
 
Share this answer
 
v2
for dispalying image in repeater control try:
XML
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
            SelectCommand="SELECT * FROM [country]"></asp:SqlDataSource>
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="Repeater1_ItemDataBound">
         <ItemTemplate>
             <asp:HiddenField Value='<%# Eval("id") %>' ID="HiddenField1" runat="server" />
             <asp:Image ID="Image1" runat="server" />
         </ItemTemplate>
        </asp:Repeater>


and in 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";
       }



   }




for more refer :
http://www.dmxzone.com/go?12760[^]

http://stackoverflow.com/questions/2629723/how-do-you-display-a-list-of-images-from-a-folder-on-hard-drive-on-asp-net-web[^]
 
Share this answer
 
v3
Comments
Member 11202135 24-Nov-14 23:35pm    
second image overwrites the first image
Try this for displaying image using repeater control, guess it helps you..

Display Image
 
Share this answer
 
Check this link it will help you:

http://stackoverflow.com/questions/7885444/how-to-show-image-in-the-column-of-repeater-control-in-asp-net[^]

Application you have to do your self.It will help you to create that application.
 
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