Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
how to retrive image form database and show in image control in asp.net


i use this for retrive image


C#
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EatProject"].ToString());

        con.Open();
        string str = "select Name,ImagePath,Link,Status from ImagesPath where ID ='" + DropDownList1.SelectedItem.Text + "'";
        cmd = new SqlCommand(str, con);

        dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            TextBox4.Text = dr["Name"].ToString();
            //Image1.ImageUrl = dr["Imagepath"].ToString();
            TextBox5.Text = dr["Link"].ToString();
            TextBox6.Text = dr["Status"].ToString();
           
        }
        con.Close();


but image is not show in image control
Posted
Updated 18-Feb-13 19:17pm
v2
Comments
Nandakishore G N 19-Feb-13 1:34am    
are you storing image path or path with the url..i.e, virtual path during development

 
Share this answer
 
Hi Dear,
Please refer my previous post from below link

How to show images in image control which are all ready present in the database[^]
 
Share this answer
 
Comments
M@anish 19-Feb-13 1:12am    
i want show image only in image control not in grideview control image retrieve from database please help me
Mr. Mahesh Patel 19-Feb-13 1:20am    
one question is there....

You have stored image bytes or image path in database...?
Mr. Mahesh Patel 19-Feb-13 1:18am    
ya, but you can reference this post, do not use complete. this is just guide my dear.
Mr. Mahesh Patel 19-Feb-13 1:19am    
other wise you have to store image physically and give path to your image control.

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