I've got a database of 9 images, which keep altering, and so i cannot directly set the src in html <img> tag to show the 9 images, I must pick them in the database and bind them accordingly.

I am in a position to retrieve and print 1 image using Response.BinaryWrite(), although not all 9. My byte[] will get just the first image in the db,

here's the code,

            while (dr.Read())
                Response.ContentType = "image/jpg";


How do you retrieve all 9 images, and just how will i bind these to either <asp:Image> tag or construct an html <img> tag dynamically

I am a novice, so please enjoy me, if you will find stupid mistakes )

Thanks ahead of time.

You cannot have the site provide the content of all of the images.

To be able to "dynamically" render the look you have to create a page which provides you with just one image. This site would use code like that which you have above.

Then to choose which image to exhibit the hyperlink to the page would change for instance




The code in make image would then return the only image.

An email -- you'll be much more happy if one makes the url


Thus getting the look url finish within the extension. Some browsers (IE) cheat and check out the finish from the string to determine what content type to anticipate. They are effective having a url like above although not with no trialling .digital.

Also, you will have to implement some type of caching our your speed and agility is a dog (esp by trying to scale.)

Best of luck.

Use HttpHandler and get in touch with Img tag

an example

<%@ WebHandler Language="C#" Class="Handler2" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public class Handler2 : IHttpHandler {

    public void ProcessRequest(HttpContext context)

        if (context.Request.QueryString["pid"] != null)
            string ID = context.Request.QueryString["pid"].ToString();

            if (dt.Rows.Count > 0)
                int pid = Convert.ToInt32(ID);
                SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);
                //int i = Convert.ToInt32(context.Request.QueryString["id"]);
                string sql = "Select BackGroundImage from Wall_BackgrndImg_Master where FK_Company_Master=@ImageId";
                SqlCommand cmd = new SqlCommand(sql, myConnection);
                cmd.Parameters.Add("@ImageId", SqlDbType.Int).Value = pid;
                SqlDataReader dr = cmd.ExecuteReader();
                    context.Response.ContentType = "jpg";



    public bool IsReusable {
        get {
            return false;


and call like

    <img src="~/handlor.ashx?pid=1">
<img src="~/handlor.ashx?pid=2">
<img src="~/handlor.ashx?pid=3">
<img src="~/handlor.ashx?pid=4">
<img src="~/handlor.ashx?pid=5">