1
Answer

how to display images on the datgrid??

I'm working on a website development using C# and asp.net, the main idea of website is online shopping using smart cards, one user post an item, store all it's information on the database (title, category, photo, price, user ID who post it, and the delivery point). Everything is going alright until I came to the point where I've to store the photo in the database, well at the beginning I made photo column in the database of varchar data type, so i can store the image URL in the server. But then stuff got more complicated, so i've decided  to change the column data type to image, well the process went a lot better, i've stored the image successfully, using the following code:

int len = File1.PostedFile.ContentLength;
            byte[] pic = new byte[len];
            File1.PostedFile.InputStream.Read (pic, 0, len);
con=new SqlConnection();
            con.ConnectionString = "Data Source=(local);Initial Catalog=sudasmart;Integrated Security=SSPI";
            cmd=new SqlCommand("INSERT INTO Products(Name,Descriptions,photo,details,category,price,Drop_Point,Contact_check)Values('"+ptitle.Text+"','"+pdescript.Text+"',@pic,'"+pdetails.Text+"','"+pcat.SelectedValue+"',"+iprice+",'"+dropoint.SelectedValue+"','"+cntmthd.SelectedValue+"')",con);
           
            cmd.Parameters.Add("@pic", pic);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close(); 

where "File1" is the file input ID.
he problems all started when i want to, retrieve the information from the database, and display them on the datagrid.
So can you provide me with the need help?? thank you for taking time reading this
Answers (1)