newbie: Help, I have problems with this!

Discussion in 'ASP .Net' started by Jeff, Jul 2, 2006.

  1. Jeff

    Jeff Guest

    hey

    asp.net 2.0
    visual web developer 2005 express

    I have a webpage which contains 1 Repeater control. Into this repeater
    control I want to add several rows of data. My problem is that 1 of the data
    is an array of bytes (it's a picture saved to the database as bytes) and I
    want that picture to be displayed nicely in the repeater list....

    Here is two approaches (approach A and approach B) I'm trying:

    APPROACH A:
    Use the scenario of 2 .aspx files, 1 .aspx (A) convert the bytes of array
    into a picture and the other .aspx file (B) has a img tag pointing to the
    first .aspx file (A)

    But here I get problems with this line "img.Src =
    "Thumnail.aspx?ImageID=1";", it looks like it expects a object... Somehow I
    need to send over a parameter to this Thumbnail.aspx file about which image
    to display... Lets say the resultset has many images, but this row shall
    display one particular image

    protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
    e)
    {
    System.Web.UI.HtmlControls.HtmlImage img = null;
    if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
    ListItemType.AlternatingItem)) {
    img =
    (System.Web.UI.HtmlControls.HtmlImage)e.Item.FindControl("Photo");
    img.Src = "Thumnail.aspx?ImageID=1";
    }
    }

    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="true" CodeFile="inbox.aspx.cs"
    Inherits="webForms_Profile_inbox" Title="Untitled Page" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="content" Runat="Server">
    <asp:ObjectDataSource ID="odsInbox" runat="server"
    SelectMethod="getInbox" TypeName="BusinessLogic.NetworkLogic">
    </asp:ObjectDataSource>
    <asp:Repeater ID="rptInbox" runat="server" DataSourceID="odsInbox"
    OnItemDataBound="rptInbox_ItemDataBound">
    <ItemTemplate>
    <tr>
    <td bgcolor="#CCFFCC">
    <%# Eval("Name") %>
    <img ID="Photo" src="" />
    </td>
    </tr>
    </ItemTemplate>

    </asp:Repeater>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="sidebar" Runat="Server">
    </asp:Content>

    ****************************************************************
    APPROACH B:

    In this approach I tryed to replace the img tag with a Image control in the
    repeater.
    But the "System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);"
    gives this error:
    "Parameter is not valid."

    Another thing is that I'm not sure this is a good approach because it uses
    bmp.Save() and I'm afraid the server will run out of space if images get
    saved on the server each time th page is displayed???


    protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
    e)
    {
    //System.Web.UI.HtmlControls.HtmlImage img = null;
    System.Web.UI.WebControls.Image img = null;

    if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
    ListItemType.AlternatingItem)) {
    img =
    (System.Web.UI.WebControls.Image)e.Item.FindControl("Photo");
    byte[] data = Profile.Picture;

    Int32 offset = 78;
    System.IO.MemoryStream mstream = new System.IO.MemoryStream();
    mstream.Write(data, offset, data.Length - offset);
    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);

    bmp.Save(Server.MapPath("sample.jpeg"),
    System.Drawing.Imaging.ImageFormat.Jpeg);
    mstream.Close();
    img.ImageUrl = Server.MapPath("sample.jpeg");

    }

    //e.Item.DataItem.ToString();
    }


    Please help me with this one, I'm stucked in this problem....

    Best Regards

    Jeff
    Jeff, Jul 2, 2006
    #1
    1. Advertising

  2. Jeff

    ReyN Guest

    ReyN, Jul 3, 2006
    #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. =?Utf-8?B?cmdyYW5kaWRpZXI=?=

    Can I have base class derived from System.Web.UI.Page have design

    =?Utf-8?B?cmdyYW5kaWRpZXI=?=, Jul 22, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    467
    Patrice
    Jul 22, 2005
  2. okaminer
    Replies:
    3
    Views:
    297
    okaminer
    Aug 1, 2005
  3. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    6
    Views:
    5,475
    Kevin Spencer
    Aug 18, 2005
  4. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    Does a resource have to have all phrases in it?

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Jan 30, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    369
    Neil Ni
    Feb 3, 2006
  5. Shelly

    Problems, problems for newbie

    Shelly, Sep 2, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    2,171
    Shelly
    Sep 3, 2007
Loading...

Share This Page