Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > newbie: Help, I have problems with this!

Reply
Thread Tools

newbie: Help, I have problems with this!

 
 
Jeff
Guest
Posts: n/a
 
      07-02-2006
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.FindC ontrol("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.FindContro l("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


 
Reply With Quote
 
 
 
 
ReyN
Guest
Posts: n/a
 
      07-03-2006
hi Jeff

I think I've covered this in a previous thread, but anyways

on this page is an example of dynamically displaying binary image data
on a Web page. this uses a GridView but the logic's the same

http://authors.aspalliance.com/aspxt...narywrite.aspx

==============================
Reynald V. Nuņez
http://authors.aspalliance.com/aspxtreme

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I have to have the WEP # set for file sharing? =?Utf-8?B?SGVscCBtZSBJIGNhbicndCBzaGFyZSE=?= Wireless Networking 3 11-01-2005 05:37 AM
have you got any of these i can have spike240 Case Modding 4 09-14-2005 03:48 AM
do i have to have.... =?Utf-8?B?amFrZQ==?= Wireless Networking 1 03-11-2005 06:05 PM
do I have to have a windows OS to start a New pc when the mwssage no ntldr foun darinsray Microsoft Certification 3 04-28-2004 06:50 AM
do I have to have a windows OS to start a New pc when the mwssage no ntldr foun darinsray Microsoft Certification 0 04-24-2004 06:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57