display an image from the database

Discussion in 'ASP .Net' started by =?Utf-8?B?VGh1YmFpdGk=?=, Dec 27, 2004.

  1. 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 ?!
    =?Utf-8?B?VGh1YmFpdGk=?=, Dec 27, 2004
    #1
    1. Advertising

  2. 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

    "Thubaiti" <> wrote in message
    news:...
    > 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 ?!
    Eliyahu Goldin, Dec 27, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandi
    Replies:
    3
    Views:
    1,743
    Natty Gur
    Nov 6, 2003
  2. Olav Tollefsen

    How to display image blob from database?

    Olav Tollefsen, Apr 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,369
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Apr 25, 2004
  3. =?Utf-8?B?U1M=?=
    Replies:
    3
    Views:
    3,808
    Juan T. Llibre
    May 15, 2005
  4. Replies:
    1
    Views:
    1,249
    Metalore
    Oct 18, 2006
  5. Replies:
    1
    Views:
    213
Loading...

Share This Page