Jaya Prakash

Jaya Prakash

  • 532
  • 2.2k
  • 49k

How to display image from db to gridview

Mar 1 2023 9:50 AM

 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 

 <asp:TemplateField HeaderText="Image">

  <ItemTemplate >

    <asp:Image ID="Image1" runat="server" ImageUrl ='<%#Eval("aadhar") %>' height="120px" Width="150px" />

  </ItemTemplate>

</asp:TemplateField>

 


Answers (8)