bindin binay type image to image control in list iew.

Posted by Snvrk1985 under ASP.NET on 6/22/2012 | Points: 10 | Views : 766 | Status : [Member] | Replies : 1
i want to show the image to image control which is in list view. The image in data base is in binary format.
i want to show the image using linq to sql.
send me sample code.




Responses

Posted by: Johnbhatt on: 7/6/2012 [Member] Starter | Points: 25

Up
0
Down
This is code copies from My Project. I have table Column of Image Type and Here How I displayed it.
        SqlCommand comm = new SqlCommand();

byte[] bt;
try
{
comm.CommandText = "select * from tblusers where uname=@uname";
comm.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
comm.CommandType = CommandType.Text;
comm.Parameters.AddWithValue("@uname", TextBox1.Text);
comm.Connection.Open();
if (comm.Connection.State == ConnectionState.Open)
{
SqlDataReader dr = comm.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
bt = ((byte[])dr["profilePic"]);
Response.BinaryWrite(bt);
}
}
}
catch (Exception ex)
{

throw;
}

I hope this must help you.

John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Snvrk1985, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response