473,569 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional item template for a datalist

Hi,

I have the following item template in a datalist:
<asp:LinkButt on id="lnkAction" runat="server" CommandName="Ac tion"
cssClass="TabMe nu">
<%# Container.DataI tem("Title") %>
</asp:LinkButton>
This is working fine until I was asked to made this template conditional
based on
the content of <%# Container.DataI tem("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 2509
On Wed, 27 Jul 2005 11:27:03 -0500, Ed Chiu""
<Ed****@discuss ions.microsoft. com> wrote:
Hi,

I have the following item template in a datalist:
<asp:LinkButt on id="lnkAction" runat="server" CommandName="Ac tion"
cssClass="TabMe nu">
<%# Container.DataI tem("Title") %>
</asp:LinkButton>
This is working fine until I was asked to made this template conditional
based on
the content of <%# Container.DataI tem("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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5309
by: Nevyn Twyll | last post by:
I have a DataList; in the DataList's , I have a LinkButton and a few listboxes. When the LinkButton is pressed, I need to get the ID of the selected item in one of the Listbox controls. Then I want to launch another web page in a seperate window, using that ID. In the header of the web page, I have a javascript function LaunchMyWindow(iID)...
2
1951
by: Jerry Camel | last post by:
One of the fields in my datalist is an expiration time. How can I make that time show in red if it is less than one hour away? Thanks. Jerry
23
449
by: Wayne Wengert | last post by:
In a Datagrid I have a field (<td>) in which I want to display a link if a database field is still Null but I want to display a blank (&nbsp;) if that DB field has a value. If I try to put the "..If ...Then..) within the TD it simply displays that as text. I am not sure how to code this conditon? What I am trying to accomplish is something...
3
9877
by: Stimp | last post by:
I have a datalist that outputs a link to a picture in each ItemTemplate: e.g. <asp:DataList id="DataList1" ...etc> <ItemTemplate> <a href='Pic.aspx?pic=somenumber'>picture</a> </ItemTemplate> <asp:DataList> What I want to do is set the "pic=somenumber" querystring value
3
2696
by: pierre.basson | last post by:
Hi, I have a DataList with an Item Template that contains an image and three radio buttons, which are used to indicate the image's status. How can I set the appropriate radio button to checked, when I load the DataList from the database? Thanks in advance. Pierre
5
13376
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able to get a Boolean value TRUE or FALSE when a checkBox is selected. When the checkBoxList was out of the DataList i used "OnSelectedIndexChanged"...
2
2350
by: mharness | last post by:
Hello, Can anyone tell me how to vertically align the contents to the top of an item template in a datalist? Many thanks, Mike
1
1982
by: footballhead | last post by:
I have a datalist on a page and I'd like to inlcude a panel that I can show or hide for each item in the list. Actually, I only want to show 1 panel at a time. Is this possible? I was thinking that to do this I would use a panel in the template. But in order to control the panels, they would each have to own unique ID assigned. How do I...
2
889
by: Miguel | last post by:
Hello, I have a DataList with the results of a search. The ItemTemplate of the DataList is a Repeated template with all the records. I have a Link Button with a Command Name called Select that allows me to show the user extended information about the record. ( This view is the Selected Item template view ). Here I have a "Back" Button....
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.