0

In .NET(C#), I'm loading an image. The src of the image is stored in the database.

I currently retrieve text from my db using this:

TextBox4.Text = reader["descr"].ToString(); // snippet

However, I want to know, how would I display an image?

Image1.Text= reader["img1"].ToString();

and then in my WebForm:

<asp:Image ID="Image1" runat="server" />
John Saunders
  • 160,644
  • 26
  • 247
  • 397
michaelmcgurk
  • 6,367
  • 23
  • 94
  • 190

3 Answers3

3

Use the ImageUrl property instead.

Try

Image1.ImageUrl = reader["img1"].ToString();
Bala R
  • 107,317
  • 23
  • 199
  • 210
0

Have you tried Image1.ImageUrl = reader["img1"].ToString();

Jim Bolla
  • 8,265
  • 36
  • 54
0

This one has been answered many times on so:

Basically you need to create an image handler to load the binary stream of the image to the browser. Also if you are going this route, please remember to use the cache header for each image so you are not pulling data from your database on every request.

ASP.NET [Image Handler]

Enjoy!

Community
  • 1
  • 1
Doug
  • 5,268
  • 24
  • 31