i am trying to display img from db to grid view but it is not working pls help me i image was successfully inserted but unable to display
void GridView()
{
string q = "select * from masterwithimg";
SqlCommand cmd = new SqlCommand(q, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
This is my source
Naimish MakwanaPosted Mar 2, 2023, 3:55 AM
Hello Jaya,
If the "aadhar" column contains the full file path of the image, you can modify your code to use the "~/" prefix to specify the root directory of the website and set the ImageUrl property to the value of the "aadhar" column:
Thanks
Naimish Makwana
Jaya PrakashPosted Mar 10, 2023, 7:41 AM
Jaya PrakashPosted Mar 10, 2023, 4:08 AM
Jaya PrakashPosted Mar 2, 2023, 3:14 AM
@NIMISH SIR THE DATA IS IMAGE FILE .JPG AND PNG AND JFIF
Sachin SinghPosted Mar 1, 2023, 1:07 PM
On browser right click and inspect the ImageUrl (src for img in browser) and check the path.
If you are storing the filename in DB then modify the url as
Naimish MakwanaPosted Mar 1, 2023, 12:25 PM
What is are the data in aadhar field?
Jaya PrakashPosted Mar 1, 2023, 12:09 PM
This is my table
the aadhar is a name given to a column i successfully inserted image but unable to display it in gridview
Naimish MakwanaPosted Mar 1, 2023, 9:58 AM
Hello Jaya,
it seems like you are trying to bind the "aadhar" field as the image URL. Make sure that the "aadhar" field in the database contains a valid image URL or base64 encoded image string.
Thanks
Naimish Makwana