473,789 Members | 2,732 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 4062
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
1259
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
10720
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
1470
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
3025
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
1970
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
1480
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
6723
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
12233
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
3489
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
9666
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
9511
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
10200
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
10139
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
7529
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
6769
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
5418
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...
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.