<ItemTemplate>
<tr class="DataListStyle">
<td><%# Html.Encode((string)DataBinder.Eval(Container.DataItem, "Title"))
%></td>
<td><a href="/Advert/Modify/<%# Eval("ID") %>">Modify</a></td>
<td>
<% if ((bool)DataBinder.Eval(Container.DataItem, "CanPublish")) { %>
<a href="/Advert/Publish/<%# Eval("ID") %>" onclick="return
confirm('Re-publish this advert?');">
Publish</a>
<% } %>
<% if ((bool)Eval("CanWithdraw")) { %>
<a href="/Advert/Withdraw/<%# Eval("ID") %>" onclick="return
confirm('Withdraw this advert?');">
Withdraw</a>
<% } %>
</td>
</tr>
</ItemTemplate>
Can someone please tell me how I am supposed to implement the <% if %>
statements in the above markup? I am using the Web Extensions so I don't
have a <form runat="server">. This is annoying me :-) Surely it should be
simple enough to output different HTML depending on a boolean?
Thanks
Pete
sloan - 19 Mar 2008 16:15 GMT
See this post for an idea:
http://groups.google.com/group/microsoft.public.dotnet.general/msg/9738c9b0c5f2412f
> <ItemTemplate>
> <tr class="DataListStyle">
[quoted text clipped - 24 lines]
>
> Pete
Peter Morris - 19 Mar 2008 17:34 GMT
Good idea, I will try that, thanks!
bruce barker - 19 Mar 2008 16:48 GMT
write support functions, and call them:
<td>
<a href="<%# GetUrl(Container.DataItem)%>"
onclick="<%# GetClientClick(Container.DataItem)%>"
>
<%# GetText(Container.DataItem)%>
</a>
</td>
-- bruce (sqlwork.com)
> <ItemTemplate>
> <tr class="DataListStyle">
[quoted text clipped - 24 lines]
>
> Pete
Peter Morris - 19 Mar 2008 17:31 GMT
The question was how do I do the "if" part?
>> <% if ((bool)Eval("CanWithdraw")) { %>
I can't get hold of CanWithdraw for the current item. Container.DataItem
throws an exception that there is no Container.
Pete
bruce barker - 19 Mar 2008 18:11 GMT
you put the if in the methods GetUrl, etc.
in a repeator only binding expressions have access to the dataitem.
-- bruce (sqlwork.com)
> The question was how do I do the "if" part?
>
[quoted text clipped - 4 lines]
>
> Pete