Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I get value of Eval() from repeater 1

Status
Not open for further replies.

AndyH1

Programmer
Jan 11, 2004
350
GB
I'm using a repeater control and want to add some processing in it so that when the page equals the link the class on that link is set to selected (see below)

The problem is I want to get the value that is held in
<%# Eval("url") %> on each 'loop' and use it within the code. I thought
<%
s = Eval("url")
%>
would work, but obviously I'm misunderstanding the system. Is there anyway to get the value held in Eval("url") outside a <%# %> statement, or is this just not possible.


<asp:Repeater ID="Repeater1" runat="server" DataSourceID="XmlDataSource1">
<HeaderTemplate>
<clear />
<div id="Menu">
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><a href="<%# Eval("url") %>" alt="<%# Eval("description") %>"
<%
Dim pagestr As String
Dim s As String
s = Eval("url")
pagestr = Mid(Request.ServerVariables("URL"), InStrRev(Request.ServerVariables("URL"), "/") + 1)
If StrComp(pagestr, s) = 0 Then
Response.Write(" class=""selected""")
End If%>><%# Eval("title") %></a></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</div>
</FooterTemplate>
</asp:Repeater>

I'm trying to create a side menu in which the current page's link is in bold and all the others plain. I can't use the ASP2 menu conrol as unfortunately I'm building some pages within someone elses site and theyv'e made modifications to this control which mean I can't control the style.
 
Any processing should be done in the code behind page. You can use the ItemDataBound event of the repeater to do what you are trying to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top