Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
i stored the image path in database using server.mappath the path is stored. i want to show the image from newly stored path in repeater. the image was not shown. i dont know the problem the
in code behind
"Upload succesfully";
            con.Open();
            string command1 = "insert into gallery (galleryimage) values ('" + path + "')";
            SqlCommand cmd1 = new SqlCommand(command1, con);
            cmd1.ExecuteNonQuery();
            con.Close();
        }
        catch (Exception ex)
        {
            Label3.Text="error"+ex.Message.ToString();
        }
    }
}
public void bind2()
{
    con.Open();
    SqlDataAdapter da1 = new SqlDataAdapter("select galleryimage from gallery", con);
    DataTable dt1 = new DataTable();
    da1.Fill(dt1);
    Rp1.DataSource = dt1;
    Rp1.DataBind();
}
protected void Viewfile_Click(object sender, EventArgs e)
{
    bind2();
}


in source code
<asp:FileUpload ID="Fileup" runat="server" />
         <br />
         <br />
         <asp:Button ID="BtnSave" Text="Upload" runat="server" onclick="BtnSave_Click" />
         &nbsp;&nbsp;&nbsp;
             <asp:Label ID="Label3" runat="server"></asp:Label>
             <br />
         <br /><br />
         <asp:Repeater ID="Rp1" runat="server">
         <ItemTemplate>
         <table>
         <tr>
         <td width="100%" height="100%">
         <img src='<%#Eval("galleryimage") %>' height="100%" width="100%" />
         </td>
         </tr>
         </table>
         </ItemTemplate>
             </asp:Repeater>


i found mistake in database it store the path as like D:\image\
but we have to get the path like D:/image

tel me the solution
Posted
Updated 12-May-11 2:44am
v3

1 solution

/* Your Need to contact Your Image Location Folder path and  Image Name retrieve from the DataBase in the f0llowing way. */

<asp:Image ID="ImageButton2" ImageUrl='<%# String.Concat("Image/", Eval("ProductImage")) %>' Width="50%" Height="30%" runat="server" />
 
Share this answer
 
v2
Comments
Mahendra.p25 12-May-11 6:05am    
post your code
beginner in C#.net 12-May-11 9:29am    
its working my5
beginner in C#.net 12-May-11 9:29am    
great job friend
Mahendra.p25 13-May-11 0:29am    
Thanks

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