473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Repeater problems again!

Hey

asp.net 2.0

I have a repeater control in my webpage (you see my code below). In this
control's ItemDataBound event I set the ImageUrl of a Image object. My
problem is that when I run this webpage it shows only 1 image... -the
repeater displays 2 rows, but it's only the first row that displays the
image...

I want each repeater row to display it's image, Any ideas what I should do
to fix this?

This is my repeater control in my webpage:
<asp:Repeater ID="rptInbox" runat="server" DataSourceID="odsInbox"
OnItemDataBound="rptInbox_ItemDataBound">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td bgcolor="#CCFFCC">
<%# Eval("Name") %>
<asp:Image ID="photo" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>

In this ItemDataBound I have this code:
protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
e) {
System.Web.UI.WebControls.Image img = null;
if (e.Item.ItemType == ListItemType.Item){
img = (System.Web.UI.WebControls.Image)e.Item.FindContro l("photo");
img.ImageUrl = "~/images/test.jpeg";
}
}

I know this line "img.ImageUrl = "~/images/test.jpeg";" may look strange,
but I'm hardcoding this now to see if I get the images displayed correctly.
When images are displaying correctly then I will modify that line to display
images dynamica

This is the html source taken from the browser:
<table>
<tr>
<td bgcolor="#CCFFCC">
test1
<img id="ctl00_content_rptInbox_ctl01_photo"
src="../../images/test.jpeg" style="border-width:0px;" />
</td>
</tr>

<tr>
<td bgcolor="#CCFFCC">
test2
<img id="ctl00_content_rptInbox_ctl02_photo" src=""
style="border-width:0px;" />
</td>
</tr>

</table>
lly
Jul 3 '06 #1
1 1259
Jeff wrote:
Hey

asp.net 2.0

I have a repeater control in my webpage (you see my code below). In
this control's ItemDataBound event I set the ImageUrl of a Image
object. My problem is that when I run this webpage it shows only 1
image... -the repeater displays 2 rows, but it's only the first row
that displays the image...

I want each repeater row to display it's image, Any ideas what I
should do to fix this?

This is my repeater control in my webpage:
<asp:Repeater ID="rptInbox" runat="server" DataSourceID="odsInbox"
OnItemDataBound="rptInbox_ItemDataBound">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td bgcolor="#CCFFCC">
<%# Eval("Name") %>
<asp:Image ID="photo" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>

In this ItemDataBound I have this code:
protected void rptInbox_ItemDataBound(object sender,
RepeaterItemEventArgs e) {
System.Web.UI.WebControls.Image img = null;
if (e.Item.ItemType == ListItemType.Item){
img =
(System.Web.UI.WebControls.Image)e.Item.FindContro l("photo");
img.ImageUrl = "~/images/test.jpeg"; }
}

I know this line "img.ImageUrl = "~/images/test.jpeg";" may look
strange, but I'm hardcoding this now to see if I get the images
displayed correctly. When images are displaying correctly then I will
modify that line to display images dynamica

This is the html source taken from the browser:
<table>
<tr>
<td bgcolor="#CCFFCC">
test1
<img id="ctl00_content_rptInbox_ctl01_photo"
src="../../images/test.jpeg" style="border-width:0px;" />
</td>
</tr>

<tr>
<td bgcolor="#CCFFCC">
test2
<img id="ctl00_content_rptInbox_ctl02_photo" src=""
style="border-width:0px;" />
</td>
</tr>

</table>
lly
Change
if (e.Item.ItemType == ListItemType.Item){
in:
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem){

It's a classical error, and having only 2 items made it more confusing.
If you would have had 10 items, they would have been alternating.

--

Riki
Jul 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Scott Lyon | last post by:
I am having a strange problem. The program is a bit complex, but I'll try to simplify what I can. I apologize if this is complicated, but I think this would still be simpler than posting a bunch of...
9
by: Ric | last post by:
im new to asp.net. please help if u can. is it possible to refer to a control(ie lable, placeholder, textbox) that is inside a repeater object from a code behind file? when i place the control...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
2
by: buran | last post by:
Dear ASP.NET Programmers, Here's my problem: I have a page (as usual :), in which I'm going to display invoices in a repeater control. I am binding data to the repeater control (ID: repHospCosts)...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
0
by: riddion | last post by:
Hello. I am having problems with the repeater webform control. Inside the <ItemTemplate> section I have a Calendar control. This is for so the user can choose a different date on each of the...
4
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString;...
4
by: John Kotuby | last post by:
Hi all, I am using a Repeater in conjunction with a SQLDatasource and SQL Server. One of the controls in the repeater is a HyperlLink as follows: <asp:HyperLink...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.