Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 27th, 2008, 08:27 AM
Authorized User
 
Join Date: Sep 2004
Posts: 67
Thanks: 1
Thanked 0 Times in 0 Posts
Default

That worked like a charm! Thanks so much for your help Imar!

By the way, I'm not sure what you mean by "Shouldn't the[list] be located in a different template like the HeaderTemplate?". Here's my entire repeater code, if you have a moment to look over it feel free to let me know what it is that I'm doing wrong.

Code:
<asp:Repeater runat="server" ID="videoRepeater">
<itemtemplate>
<div id="MainContainer">
<div id="ColumnContainer">
<div id="Column1">
<span class="TitleFont">
<p><%# DataBinder.Eval(Container.DataItem, "sVideoTitle") %></p>
</span>
<span class="StandardFont">
<p><%# DataBinder.Eval(Container.DataItem, "sVideoBlurb") %></p>
</span>
<div id="Link">[list]
<li id="video" runat="server" Visible='<%# Eval("iVideoId") IsNot DBNull.Value %>'>
<asp:Hyperlink runat="server" 
NavigateUrl='<%# "video.aspx?id=" & DataBinder.Eval(Container.DataItem, "iVideoId") %>' 
Text='Watch video'></asp:Hyperlink>
</li>
</ul>
</div>
</div>
<div id="Clear">&nbsp;</div>
</div>
<div id="Column2">
<span class="StandardFont">
<p><b>Duration:</b> <%# DataBinder.Eval(Container.DataItem, "sVideoDuration") %></p>
<p><b>Rating:</b> [<%# DataBinder.Eval(Container.DataItem, "sVideoRating") %>]</p>
<p><b>Publish Date:</b> <%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "dVideoPublished")).ToString("d MMMM yyyy") %></p>
</span>
</div>
</div>
</itemtemplate>
<separatortemplate>
<div id="Spacer">&nbsp;</div>
</separatortemplate>
</asp:Repeater>
 
Old February 27th, 2008, 08:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Maybe you're not doing anything wrong; it just depends on what you are doing. I noticed this:
Code:
[list]
<li id="video" runat="server" Visible='<%# Eval("iVideoId") IsNot DBNull.Value %>'>
  HyperLink here
</li>
</ul>
With this setup, you repeat the[list] element for each and every item in your data source. This is perfectly fine if all you want is a single bullet in front of the link, which is surrounded by other content.

However, since I didn't know your entire code, I assumed you wanted a <li> for each item in the data source and use the[list] element as a container. Normally, this is accomplished like this:
Code:
<asp:Repeater ...>
  <HeaderTemplate>[list]</HeaderTemplate>
  <FooterTemplate></ul></FooterTemplate>
  <ItemTemplate><li>...</li></ItemTemplate>
</asp:Repeater>
Here the Footer and Header define the outer[list] element. The ItemTemplate than defines individual <li> elements.

But, in your case, it seems to make sense, as you have other content in the ItemTemplate as well.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP:Repeater and Mouseover gbrown ASP.NET 1.0 and 1.1 Basics 1 June 4th, 2007 01:17 AM
hyperlink in nested datalist calling a repeater debjanib C# 1 May 25th, 2006 08:17 AM
Hyperlink in repeater control? johno ASP.NET 2.0 Professional 1 April 19th, 2006 05:22 AM
ASP Repeater without DataBinder safin ASP.NET 2.0 Professional 1 February 3rd, 2006 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.