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="o dsInbox"
OnItemDataBound ="rptInbox_Item DataBound">
<HeaderTemplate >
<table>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td bgcolor="#CCFFC C">
<%# 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_ItemDa taBound(object sender, RepeaterItemEve ntArgs
e) {
System.Web.UI.W ebControls.Imag e img = null;
if (e.Item.ItemTyp e == ListItemType.It em){
img = (System.Web.UI. WebControls.Ima ge)e.Item.FindC ontrol("photo") ;
img.ImageUrl = "~/images/test.jpeg";
}
}
I know this line "img.ImageU rl = "~/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="#CCFFC C">
test1
<img id="ctl00_conte nt_rptInbox_ctl 01_photo"
src="../../images/test.jpeg" style="border-width:0px;" />
</td>
</tr>
<tr>
<td bgcolor="#CCFFC C">
test2
<img id="ctl00_conte nt_rptInbox_ctl 02_photo" src=""
style="border-width:0px;" />
</td>
</tr>
</table>
lly 1 1270
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="o dsInbox"
OnItemDataBound ="rptInbox_Item DataBound">
<HeaderTemplate >
<table>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td bgcolor="#CCFFC C">
<%# 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_ItemDa taBound(object sender,
RepeaterItemEve ntArgs e) {
System.Web.UI.W ebControls.Imag e img = null;
if (e.Item.ItemTyp e == ListItemType.It em){
img =
(System.Web.UI. WebControls.Ima ge)e.Item.FindC ontrol("photo") ;
img.ImageUrl = "~/images/test.jpeg"; }
}
I know this line "img.ImageU rl = "~/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="#CCFFC C">
test1
<img id="ctl00_conte nt_rptInbox_ctl 01_photo"
src="../../images/test.jpeg" style="border-width:0px;" />
</td>
</tr>
<tr>
<td bgcolor="#CCFFC C">
test2
<img id="ctl00_conte nt_rptInbox_ctl 02_photo" src=""
style="border-width:0px;" />
</td>
</tr>
</table>
lly
Change
if (e.Item.ItemTyp e == ListItemType.It em){
in:
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem){
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 source code. If you want me
to post code, though, just say so.
In a nutshell, I've got an ASP.NET application that has one main ASPX page.
On that ASPX page, it has a user control (an ASCX) that displays the actual
data and controls I need.
|
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 object outside of the repeater, i can refer to it from the
code behind file. when i place the control object inside the repeater,
i get a 'need to instanciate the control object' error. if i declare
the control object inside the control behind file,...
|
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">
<HeaderTemplate><table>
</HeaderTemplate>
<ItemTemplate>
|
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) without any problems. I have also a button on the page, I am going to add a new datarow programmatically and display it when pressed. Unfortunately, I cannot refer to the dataset in the event handler of the button (or at least I think so). I get the...
|
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 fragment of a very simple page that I wrote that will drill
down into the displayed item. The result is to be display on the same
page so that the user can keep on drilling down:
| |
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 Repeater control, I've placed
DropDownLists and CheckBoxes.
When the user has updated the information, he/he clicks the submit button
which is outside the scope of the Repeater control.
|
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 items in the repeater.
I also have buttons in the <ItemTemplate> section.
The buttons' click event is catched by the repeater's ItemCommand event
and they are handled, but Calendar's SelectionChanged event is not
catched by the ItemCommand event. I...
|
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;
//open connection
SqlConnection m_conn = new SqlConnection("Server=server;
Database=database; UId=username; Pwd=password");
|
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 NavigateUrl='Search.aspx?page=base&searchid=<%
Eval("sequence")%>' .....
As you can see I am trying to pass a QueryString evaluated at runtime. All
the other Evals of DataFields in the Repeater are working just fine. However
this NavigateUrl is resolving as...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |