Showing posts with label repeater. Show all posts
Showing posts with label repeater. Show all posts

Thursday, March 29, 2012

newbie: Help, I have problems with this!

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";
}
}
<%@dotnet.itags.org. 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="http://pics.10026.com/?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
Jeffhi 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/aspx...classbinarywri=
te.aspx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
Reynald V. Nu=F1ez
http://authors.aspalliance.com/aspxtreme

newbie: Help, I have problems with this!

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";
}
}

<%@dotnet.itags.org. 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="http://pics.10026.com/?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

Jeffhi 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/aspx...inarywrite.aspx
==============================
Reynald V. Nuez
http://authors.aspalliance.com/aspxtreme

newbie: load image from db + Repeater

hey
asp.net 2.0
With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.
I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" /> )
This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}
The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!
In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...
Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event
Any ideas how I should pass over such a parameter?
Jeffhello Jeff
you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.
on this page is a similar example, though uses a GridView instead, but
logically it's the same
http://authors.aspalliance.com/aspx...te.aspx

Monday, March 26, 2012

newbie: load image from db + Repeater

hey

asp.net 2.0

With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.

I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" />)

This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}

The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!

In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...

Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event

Any ideas how I should pass over such a parameter?

Jeffhello Jeff

you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.

on this page is a similar example, though uses a GridView instead, but
logically it's the same

http://authors.aspalliance.com/aspx...inaryWrite.aspx

Saturday, March 24, 2012

newbie: repeater problem

hey

asp.net 2.0

I have a web page with a repeater control... In the ItemTemplate of the
repeater control have I placed a ImageMap. So every row in the repeater
control has a ImageMap. (it's the same ImageMap, but it's repeated to every
line in the repeater control)

A ImageMap has a "click" event. How can the click event know which ImageMap
in the repeater control has been clicked? I need to know this, because I
want to retrieve some data from that row and embedd it into a querystring

Any suggestions?

JeffJeff,

First parameter passed to the event handler is the source of the event. You
can set a breakpoint inside the handler and watch what is being passed
there.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eqWqOkSsGHA.4472@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I have a web page with a repeater control... In the ItemTemplate of the
repeater control have I placed a ImageMap. So every row in the repeater
control has a ImageMap. (it's the same ImageMap, but it's repeated to
every line in the repeater control)
>
A ImageMap has a "click" event. How can the click event know which
ImageMap in the repeater control has been clicked? I need to know this,
because I want to retrieve some data from that row and embedd it into a
querystring
>
Any suggestions?
>
Jeff
>