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
Java
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
Code
' height="120px" Width="150px" />
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 1, 2023, 10:55 PM EST
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:
' Height="120px" Width="150px" />Thanks
Naimish Makwana
Sachin SinghRank #66 · 26.2K reputationPosted Mar 1, 2023, 8:07 AM EST
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 MakwanaRank #324 · 7.7K reputationPosted Mar 1, 2023, 4:58 AM EST
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
Jaya PrakashRank #1,293 · 1.3K reputationPosted Mar 1, 2023, 7:09 AM EST
This is my table
create table masterwithimg(id int identity(1,100),name nvarchar(50),password nvarchar(50),gender varchar(20), email varchar(65),aadhar nvarchar(65),pancard nvarchar(70))the aadhar is a name given to a column i successfully inserted image but unable to display it in gridview
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 1, 2023, 7:25 AM EST
What is are the data in aadhar field?
Jaya PrakashRank #1,293 · 1.3K reputationPosted Mar 1, 2023, 10:14 PM EST
@NIMISH SIR THE DATA IS IMAGE FILE .JPG AND PNG AND JFIF
Jaya PrakashRank #1,293 · 1.3K reputationPosted Mar 9, 2023, 11:08 PM EST
body { font-family: Arial; font-size: 10pt; } .modalBackground { background-color: Black; filter: alpha(opacity=40); opacity: 0.4; } .modalPopup { background-color: #FFFFFF; width: 1000px; border: 3px solid #0DA9D0; } .modalPopup .header { background-color: #2FBDF1; height: 30px; color: White; line-height: 70px; text-align: center; font-weight: bold; } .modalPopup .body { min-height: 50px; line-height: 30px; text-align: center; padding:5px } .modalPopup .footer { padding: 3px; } .modalPopup .button { height: 23px; color: White; line-height: 23px; text-align: center; font-weight: bold; cursor: pointer; background-color: #9F9F9F; border: 1px solid #5C5C5C; } .modalPopup td { text-align:left; } function showModal() { $("#myModal").modal('show'); } $(function () { $("#btnShow").click(function () { showModal(); }); }); function Image{ $("") prakash.Image('show'); return false; }Jaya PrakashRank #1,293 · 1.3K reputationPosted Mar 10, 2023, 2:41 AM EST
function validate() { var rbList = document.getElementById(''); var rbSelected = false; for (var i = 0; i