Can I use loops in repeater? Is it reccomended?
Posted
by iTayb
on Stack Overflow
See other posts from Stack Overflow
or by iTayb
Published on 2010-03-30T14:04:45Z
Indexed on
2010/03/30
14:13 UTC
Read the original article
Hit count: 386
My datasource has an Rating
dataItem contains an integer from 0 to 5. I'd like to print stars accordignly.
I'm trying to do it within Repeater
control:
<b>Rating:</b>
<% for (int j = 1; j <= DataBinder.Eval(Container.DataItem, "Rating"); j++)
{ %>
<img src="App_Pics/fullstar.png" />
<% }
for (int j = 1; j <= 5 - DataBinder.Eval(Container.DataItem, "Rating"); j++)
{ %>
<img src="App_Pics/emptystar.png" />
<%} %>
- I get the error
The name 'Container' does not exist in the current context
. It is weird, because when I used<%# DataBinder.Eval(Container.DataItem, "Name")%>
a line before, it worked great. - Is it clever to include loops in my
aspx
page? I think it's not very convenient. What's my alternatives? - What's that
#
means?
Thank you very much.
© Stack Overflow or respective owner