Dear all
I have a varbinary(max) column in sql server database table and i am fetching this data..I am inserting image in this column
How can display image in image control or in any other way
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Krishna GaradPosted Jan 6, 2012, 8:32 AM
public class ImageHandle : IHttpHandler {
public void ProcessRequest (HttpContext context) {
string imageid = context.Request.QueryString["ImID"];
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlcn"].ConnectionString);
connection.Open();
SqlCommand command = new SqlCommand("Select ImageColumn From TblImages Where ImageId="+imageid, connection);
SqlDataReader dr = command.ExecuteReader();
if (dr.Read())
{
context.Response.BinaryWrite((Byte[])dr[0]);
//context.Response.BinaryWrite((Byte[])dr[1]);
}
connection.Close();
context.Response.End();
}
public bool IsReusable {
get {
return false;
}
}
}
and in aspx page provide Image controls imageurl property like
Image1.ImageUrl="~/ImageHandle.ashx?ImID="+someid;
Krishna GaradPosted Jan 7, 2012, 1:24 AM
Mayur GujrathiPosted Jan 7, 2012, 1:20 AM
As per my question your answer is correct but i want to do slight change in this..
When i am fetching image i dont to display iy directly..
what ever no of images i am getting i want to create as much of link button dynamically and on click of i want to generate pop up to display paricular image..
Please help