Conditional item template for a datalist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have the following item template in a datalist:
<asp:LinkButton id="lnkAction" runat="server" CommandName="Action"
cssClass="TabMenu">
<%# Container.DataItem("Title") %>
</asp:LinkButton>
This is working fine until I was asked to made this template conditional
based on
the content of <%# Container.DataItem("Title") %>. Say if it is "A" or "B"
or "C", the template will be a LinkButton, every thing else will be a Label.
I don't know how to do that.

Please help !
 
Hi,

I have the following item template in a datalist:
<asp:LinkButton id="lnkAction" runat="server" CommandName="Action"
cssClass="TabMenu">
<%# Container.DataItem("Title") %>
</asp:LinkButton>
This is working fine until I was asked to made this template conditional
based on
the content of <%# Container.DataItem("Title") %>. Say if it is "A" or
"B"
or "C", the template will be a LinkButton, every thing else will be a
Label.
I don't know how to do that.

Please help !

Somewhat ironically, I happened to be looking for something this morning
and ran across this article:

http://www.devx.com/vb2themax/Article/19908

I wasn't looking for that, I just happened to glance at it before moving
on....I assume by its title it does what you want, hopefully not
off-topic...

Note you could also use panels or placeholders inside the template and set
the visible property using databinding as well; it adds a little extra
processing as you're loading both controls, then showing/hiding according
to your title value; but I also don't know how 'complex' your templates
get, or the article I linked to, how complex that is....
 
Back
Top