473,695 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional statement to display asp:textbox or asp:label

Hi,

I have a datagrid and based on a condition I like to display either a
asp:textbox or asp:label. How would I do that? I have the following
<asp:TemplateCo lumn HeaderText="Qty ">
<ItemTemplate >
<% if (DataBinder.Eva l(Container.Dat aItem, "DynamicAttribu te") = "No")
{%>
<asp:textbox id="tbxQtyNew" BackColor='<%#
SetTextBoxColor (DataBinder.Eva l(Container.Dat aItem,
"DynamicAttribu te")) %>' runat="server" text='1' />
<% } else { %>
<asp:Label id="lblQtyDisp " Text="1" runat="server"/>
<% } %>
</ItemTemplate>

</asp:TemplateCol umn>
Which fails. Any idea?
Thanks
Maz.

Mar 2 '06 #1
1 4040
You can set the Visible property on each control accordingly. Something
like:

<asp:TextBox id="myTB" runat="server" Visible='<%# someVar = "Y" %>' />

But you of course substitute whatever boolean condition you have to
determine whether or not that item should be visible.

<ma*******@gmai l.com> wrote in message
news:11******** *************@z 34g2000cwc.goog legroups.com...
Hi,

I have a datagrid and based on a condition I like to display either a
asp:textbox or asp:label. How would I do that? I have the following
<asp:TemplateCo lumn HeaderText="Qty ">
<ItemTemplate >
<% if (DataBinder.Eva l(Container.Dat aItem, "DynamicAttribu te") = "No")
{%>
<asp:textbox id="tbxQtyNew" BackColor='<%#
SetTextBoxColor (DataBinder.Eva l(Container.Dat aItem,
"DynamicAttribu te")) %>' runat="server" text='1' />
<% } else { %>
<asp:Label id="lblQtyDisp " Text="1" runat="server"/>
<% } %>
</ItemTemplate>

</asp:TemplateCol umn>
Which fails. Any idea?
Thanks
Maz.

Mar 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1251
by: Valera Simonov | last post by:
there are some asp:textbox on page which is have to be printed. printed page looks good until text in the textbox exceeds size of it - in this case only a part of text printed. can i somehow make textbox differ in size depending on amount of text it contains?.. any solution i can figure now is to make asp:label or smth like that instead of textbox, but it' gonna be another representation of page - i don't want to do this. thanks. Shade.
6
10708
by: tfs | last post by:
I am trying to display some data that is about 200 characters long and I was trying to display it on the screen in a textbox <asp:textbox /> But I don't want any borders. How would I display that? Thanks,
1
1463
by: Ray Cacciatore | last post by:
I'm using an asp:label to display source code on my web page. The source code is formatted with carriage returns, tabs and spaces. In the past, all I had to do was wrap the label in a <pre> element and it was fine. But this time, when I wrap my asp:label inside a <pre> element, it's only recognizing the carriage returns but not the tabs or spaces. When I view the source code in NotePad, everything is properly formatted. So how do I...
1
3019
by: Shilpi Chaudhry | last post by:
I have a forloop which I use to create textboxes - but unfortunately all of them have the same ids - I need to assign different ids to these textboxes creeated in the loop so that I can retrieve their corrs values. Anybody?? Code snippet: <% int y = 7; %>
4
1964
by: Jeronimo Bertran | last post by:
I am currently using databing to show on an asp:label the result of appending two database fields in the following way: <asp:label id=textAcknowledgedBy runat="server" Text='<%# DataBinder.Eval (dataSetEventResponse1, "Tables.DefaultView..UserName") + " from " + DataBinder.Eval(dataSetEventResponse1, "Tables .DefaultView..ComputerName") %>'></asp:label>
5
1474
by: needin4mation | last post by:
Hi, I have this in my asp.net 1.1 page: <asp:textbox id="Comment" tabIndex="4" runat="server"></asp:textbox> Inside the tags, say I have: <b>I am bold.</b> When I run the page I get the tags, the HTML, with the sentence. But how can I get it to render the sentence bold using the tags?
4
6700
by: pagates | last post by:
Hello All-- I have a number of <asp:Label CssClass="someclass">Text</asp:Labelcontrols on my page. I would like them to be shown as <div class="someclass">Text</div> rather than <span class="someclass">Text</span> When it uses a span, it doesn't seem to use all the class definitions, particularly for margins and positioning.
1
12220
by: cyningeston | last post by:
OS: WinXP Pro, VB/ASP/ADO.NET I'm building a web-based supplier management application. For each supplier we are required by the FDA to track certain documents. I've managed to pull them from Access into a Gridview (Gridview1), in which I have AutoGenerateEditButton set to True. What I want is this: when a user clicks "Edit" on a line and it goes to edit mode, I want to grab the supplier's category (4th column of the grid, named...
7
3474
by: TechnoAtif | last post by:
Hi..There is again a similar problem..Now i;ve got the option values of list?menu box to show the textbox. If the option value of list is yes then the textbox is to be displayed . Can anyone help..through php or javascript. ONe more thing..How can i perform the same function for more than one such kind of problem..I mean if there is any other place in the form where i have to display textbox on selecting a particular value.how can it be...
0
8625
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9113
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8977
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6488
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5838
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4339
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2269
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.