display an image from the database

G

Guest

Hi,

I have an image web control with other web controls..

<asp:Image id="itemImage" runat="server"></asp:Image>
<asp:Label id="itemNameLabel" runat="server"></asp:Label>
<asp:Label id="itemDescribeLabel" runat="server"></asp:Label>
<asp:Label id="itemPriceLabel" runat="server"></asp:Label>

and I want to display an image in the image web control from the database..


private void itemDetail(SqlString itemId) {
sweItem.Id = itemId.ToSqlDecimal();
sweItem.SelectOne();

itemLabel.Text = sweItem.Name.ToString();
itemDetailLabel.Text = "The detail of " + itemLabel.Text + " item.";
itemNameLabel.Text = itemLabel.Text;
itemDescribeLabel.Text = sweItem.ItemDescribe.ToString();
itemPriceLabel.Text = sweItem.Price.ToString();

if(sweItem.Image != null) {
byte[] image = sweItem.Image.Value;
//what is the next step ??!?
}
}

what is the next step after getting the array of bytes ?!


Any help ?!
 
E

Eliyahu Goldin

You are not on the right track. The way of getting image from a database is
to make a separate page, say getImage.aspx, that will accept an image id as
a query parameter. In run time get the image id and set up the image url to
getImage.aspx?id=myImageId. In getImage.aspx get the image from the database
as byte array and stream it down in http response.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top