469,140 Members | 1,403 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,140 developers. It's quick & easy.

Conditional item template for a datalist

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 !
Nov 19 '05 #1
1 2381
On Wed, 27 Jul 2005 11:27:03 -0500, Ed Chiu""
<Ed****@discussions.microsoft.com> wrote:
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....

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jerry Camel | last post: by
23 posts views Thread by Wayne Wengert | last post: by
3 posts views Thread by pierre.basson | last post: by
2 posts views Thread by mharness | last post: by
1 post views Thread by footballhead | last post: by
2 posts views Thread by Miguel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.