473,748 Members | 10,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

making a server control visible / invisible in a DataList

SP
Hello there,

I have a DataList create as below.

<asp:DataList ID="dl_Immunpsu ppressive_Main" Runat="server"
Width="100%">
<ItemTemplate >
<table id="Immunpsuppr essive_Main" width="100%" border="0">
<tr>
<td class="sub" width="50%" colSpan="2">
<asp:Label ID="lbl_Imm_Mai n" Runat="server">
<%#((System.Dat a.DataRow)Conta iner.DataItem)["MetaDataChoice Text"] %>
</asp:Label>
<asp:TextBox ID="txt_Imm_Mai n_Other" Runat="server" Width="150px"
Visible="False" ></asp:TextBox>
</td>
<td class="sub" width="5%" colSpan="1">
<asp:CheckBox ID="chk_Ind" Runat="server"> </asp:CheckBox></td>
<td class="sub" width="19%" colSpan="1">
<asp:TextBox ID="txt_Days" Runat="server" Width="96px"></asp:TextBox>
</td>
<td class="sub" width="19%" colSpan="1">
<asp:DropDownLi st ID="ddl_ST" Runat="server"
Width="96px"></asp:DropDownLis t>
</td>
<td class="sub" width="5%" colSpan="1">
<asp:CheckBox ID="chk_Maint" Runat="server"> </asp:CheckBox></td>
<td class="sub" width="5%" colSpan="1">
<asp:CheckBox ID="chk_AR" Runat="server"> </asp:CheckBox></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

I need to make the TExtBox Control "txt_Imm_Main_O ther" visible only
when it meets a particular condition:

I have the following code in my DataList ItemDataBound

TextBox txt_Imm_Main_Ot her =
(TextBox)e.Item .FindControl("t xt_Imm_Main_Oth er");

if (txt_Imm_Main_O ther != null)
{
MetaDataDAC metaDataDAC_Imm = new MetaDataDAC();
DataSet ds_Imm = metaDataDAC_Imm .Get(1, 2, null);

foreach(DataTab le dt_Table in ds_Imm.Tables)
{
foreach (DataRow dr_Row in dt_Table.Rows)
{
if (dr_Row["MetaDataChoice Val"].ToString() == "4")
{
txt_Imm_Main_Ot her.Visible = true;
txt_Imm_Main_Ot her.Enabled = true;
}
}
}

}

The TExtBox Control "txt_Imm_Main_O ther" always is visible?

Please suggest!

Thanks,
Pai

Mar 1 '06 #1
1 3153
SP
Hello All,

I got the answer, I was looping through a DataSet and trying to make
the control txt_Imm_Main_Ot her visible / invisible.

I changed the MetaDataDAC metaDataDAC_Imm = new MetaDataDAC();
DataSet ds_Imm = metaDataDAC_Imm .Get(1, 2, null);
foreach(DataTab le dt_Table in ds_Imm.Tables)
{
foreach (DataRow dr_Row in dt_Table.Rows)
{
if (dr_Row["MetaDataChoice Val"].ToString() == "4")
{
txt_Imm_Main_Ot her.Visible = true;
txt_Imm_Main_Ot her.Enabled = true;
}
}

}
to:

if (txt_Imm_Main_O ther.Text == "5172")
{
txt_Imm_Main_Ot her.Text = "";
txt_Imm_Main_Ot her.Visible = true;
}
else
{
txt_Imm_Main_Ot her.Visible = false;
}

and it worked

Thanks,
Pai

Mar 1 '06 #2

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

Similar topics

0
1304
by: Yoshitha | last post by:
Hello, I have a doubt... I have a TextBox by name txtMessage.Text ,Button by name btnSend and Datalist Control by name dltMessage i my aspx page. when i enter the data in text box and click on the button it is storing the data into the database. The saved information has to displayed in the datalist....
6
2037
by: Nick Stansbury | last post by:
Hi, I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set all of the drop down lists to be visible with a straightforward recursive loop. Now - I'm really muddled by this - why does this: If TypeOf Ctl Is DropDownList Then Ctl.Visible = true End If
6
14696
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src = 'somepicture.jpg') and that works fine. I've tried some java script to change the other control's visible property by changing is className, but that doesn't seem to work
2
1960
by: BengtPelle | last post by:
I have a page with two Datalists containing X number of ImageButtons. When the user clicks on an image in Datalist1 I need to copy the image to "Obverseimg" when the user clicks an image in Datalist2 I need to copy this image to "Reverseimg". This all works fine when it uses "Runat Server". How can I do this without going back to the server? It gets much to slow refreshing all the images for every click. What Javascript can I use? Note...
10
2799
by: Carlos | last post by:
Hi all, I have a table that I would like to make it invsible depending on the validity of data retrieved. The problem is that within the code behind the reference to the table is not understood. (i.e. it says that the html control that I reference with its ID is not declared). How can I reference it, and make it invisible ? Thanks in advance,
5
12903
by: Jim in Arizona | last post by:
How do I find a control within a datalist itemtemplate from a sub procedure that isn't a normal called procedure from a datalist (like the update, edit, or cancel procedures)? For instance, normally you find a control and access it's properties and methods, like so: Sub Update(ByVal sender As Object, ByVal e As DataListCommandEventArgs) Dim txtPosted As New TextBox
1
1417
by: Sunfire | last post by:
I need to know how to position a layout table in code next to (to the right of) another table on the page? I also then need to know how to make it invisible in code. How would you do this?
5
2032
by: Andy B | last post by:
I have 2 TextBoxes and an Add button on a page. When the user fills in the TextBoxes, the values are added to a dataset table. When the page gets done reloading, the TextBoxes are turned into readonly mode, the requiredFieldValidaters are set to disabled, the character counter for each textbox is made invisible and edit buttons show up next to the read only textboxes. I want to make the Add button invisible and then make a save changes...
7
4489
by: Peter | last post by:
I have a HoverMenuExtender which contains an asp:PlaceHolder, this place holder has a User Control and this control contrains a Button. The problem I am having is after the button fires the click event I want to do a server side function and then refresh the Page where the PlaceHolder risides. I have no problem doing the server side function, but the following 'alert' never shows up after the server side funtion. I am using the alert...
0
9548
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
9374
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
9325
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,...
0
9249
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
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
6076
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
4607
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
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
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

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.