Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 02-11-2006, 04:18 AM ASP:Repeater help
Super Talker

Posts: 148
Trades: 0
Currently, i am using a asp:repeater to bind my images from database to a imagebutton. For example, i have 2 images in the database. Therefore, the repeater should have generate 2 imagebuttons for me. And each imagebutton is suppose to show 2 different images.

Somehow both imagebuttons are displaying the same images, which always happens to be the 2nd image. Before the itemdatabound, i already databind it to an arraylist. The imgRetrieve.aspx is used to retrieve/display image for me based on the id passed in. Any help is greatly appreciated.

Code:
<asp:repeater id="repImages" runat="server" OnItemDataBound="repImages_ItemDataBound">
		<ItemTemplate>
			<asp:ImageButton runat="server" ID="imgItem" CssClass="removeBorder" onmouseover="this.className='applyBorder'"
				onmouseout="this.className='removeBorder'" Width="100" Height="100" OnClick="imgItem_Click" />
			<br>
		</ItemTemplate>
	</asp:repeater>
Code:
    Protected Sub repImages_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repImages.ItemDataBound

Dim Item As RepeaterItem = CType(e.Item, RepeaterItem)
        Dim MyImage As New ImageButton
MyImage = CType(Item.FindControl("imgItem"), ImageButton)
dim index as integer=0
for index=0 to imgArrList.count-1
MyImage.ImageUrl = "..\imgRetrieve.aspx?id=" & imgArrList.item(index).staffid
end next
shaoen01 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-11-2006, 06:43 AM Re: ASP:Repeater help
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
I don't get what you mean when you say "each imagebutton is suppose to show 2 different images."
An image button can only be one image at a time.
There's no point in setting a value like that inside a For...Next statement. The value will always then be set to the value of the last element in the ArrayList.
Can you give more detail on what you're trying to do?
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 02-11-2006, 01:30 PM Re: ASP:Repeater help
vivekar's Avatar
Webmaster Talker

Posts: 612
Trades: 0
Do you mean to say that you need to show different image in the alternative rows?

Then use it like

if(e.Item.ItemType == ListItemType.Item)
{
//display image one
}
else if (e.Item.ItemType == ListItemType.AlternatingItem)
{
//display image two
}
__________________

Please login or register to view this content. Registration is FREE
(Active since 2003) |
Please login or register to view this content. Registration is FREE
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 02-12-2006, 08:49 AM Re: ASP:Repeater help
Super Talker

Posts: 148
Trades: 0
My apologies, what i meant was i was supposed to have 2 image buttons and each showing different images. However, at that time mine was showing both the same images.

I have managed to solve it already, thanks. My coding is as follows:
Code:
<asp:repeater id="repImages" runat="server" OnItemDataBound="repImages_ItemDataBound">
		<ItemTemplate>
			<asp:ImageButton runat="server" ID="imgItem" ImageUrl ='<%# DataBinder.Eval(Container.DataItem, "staffId", "imgRetrieve.aspx?id={0}") %>' 
			CssClass="removeBorder" onmouseover="this.className='applyBorder'" onmouseout="this.className='removeBorder'" Width="100" Height="100" OnClick="imgItem_Click" />
			<br>
		</ItemTemplate>
	</asp:repeater>
Quote:
Originally Posted by Minaki
I don't get what you mean when you say "each imagebutton is suppose to show 2 different images."
An image button can only be one image at a time.
There's no point in setting a value like that inside a For...Next statement. The value will always then be set to the value of the last element in the ArrayList.
Can you give more detail on what you're trying to do?
shaoen01 is offline
Reply With Quote
View Public Profile
 
Old 02-12-2006, 08:50 AM Re: ASP:Repeater help
Super Talker

Posts: 148
Trades: 0
****, i totally forgot about the e.item thing. Thanks


Quote:
Originally Posted by vivekar
Do you mean to say that you need to show different image in the alternative rows?

Then use it like

if(e.Item.ItemType == ListItemType.Item)
{
//display image one
}
else if (e.Item.ItemType == ListItemType.AlternatingItem)
{
//display image two
}
shaoen01 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ASP:Repeater help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.30772 seconds with 12 queries