Existing:
<a href="#" <%# IsCurrentDocument()?"class='selected'":"" %>><%# Eval("DocumentName") %></a>
New update:
<%# ((Eval("showMobileOnly").ToString() == "True") ? "class=\"mobile\"" : "") %>
I get this message when I attempt to: Message: [CMSAbstractTransformation.DataBind]: Object reference not set to an instance of an object. Stack Trace: Object reference not set to an instance of an object. at ASP.cmsvirtualfiles_transformations__vg_6af8409a_949e_4459_ba54_63873b287840_monarchbeachresortcom0092_sub_seperator_ascx.__DataBind__control2(Object sender, EventArgs e) at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at System.Web.UI.Control.DataBindChildren() at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at CMS.Controls.CMSAbstractTransformation.DataBind()
I'd do something like this:
class="<%# If(Eval<bool>("ShowMobileOnly"), "mobile ", "") %><%# If(IsCurrentDocument(), "selected", "") %>"
This works. But only the the item transformation. Not the Separator for some reason. It doesn't error anymore but all is returned is <li class="" >
<li class="" >
The separator is not a binding template which is why it doesn't work. There is no dataview or dataitem with a separator. I'd suggest adding some logic into your transformation if you want to get even/odd levels or just add it always to the end of the transformation and do some checking to see if it is the last one i.e.: DataItemIndex == (DataItemCount - 1) or IsLast()
dataview
dataitem
DataItemIndex == (DataItemCount - 1)
IsLast()
I understand now. Thank you.
Please, sign in to be able to submit a new answer.