hi. . .
This will be useful to retrieve the image from database, to display in a gridview
<asp:GridView runat="server" DataKeyNames="imageid" ID="Gridview1">
<Columns>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<img src="ImageRetrive.aspx?imageid=<%# Eval("imageid") %>" height="200px" width="200px" alt="Available" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Write the below in the page_load of imageRetrive.aspx
protected void Page_Load(object sender, EventArgs e)
{
int imageid = int.Parse(Request.QueryString["imageid"].ToString());
string ConnString = ConfigurationManager.ConnectionStrings["connstr"].ConnectionString;
byte[] byeteArray = new byte[5000];
using (SqlConnection con = new SqlConnection(ConnString))
{
using (SqlCommand cmd = new SqlCommand("select myimage from storeimages where imageid="+imageid, con))
{
con.Open();
byeteArray = (byte[])cmd.ExecuteScalar();
Response.BinaryWrite(byeteArray);
con.Close();
}
}
}