By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,813 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,813 IT Pros & Developers. It's quick & easy.

making a server control visible / invisible in a DataList

P: n/a
SP
Hello there,

I have a DataList create as below.

<asp:DataList ID="dl_Immunpsuppressive_Main" Runat="server"
Width="100%">
<ItemTemplate>
<table id="Immunpsuppressive_Main" width="100%" border="0">
<tr>
<td class="sub" width="50%" colSpan="2">
<asp:Label ID="lbl_Imm_Main" Runat="server">
<%#((System.Data.DataRow)Container.DataItem)["MetaDataChoiceText"] %>
</asp:Label>
<asp:TextBox ID="txt_Imm_Main_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:DropDownList ID="ddl_ST" Runat="server"
Width="96px"></asp:DropDownList>
</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_Other" visible only
when it meets a particular condition:

I have the following code in my DataList ItemDataBound

TextBox txt_Imm_Main_Other =
(TextBox)e.Item.FindControl("txt_Imm_Main_Other");

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

foreach(DataTable dt_Table in ds_Imm.Tables)
{
foreach (DataRow dr_Row in dt_Table.Rows)
{
if (dr_Row["MetaDataChoiceVal"].ToString() == "4")
{
txt_Imm_Main_Other.Visible = true;
txt_Imm_Main_Other.Enabled = true;
}
}
}

}

The TExtBox Control "txt_Imm_Main_Other" always is visible?

Please suggest!

Thanks,
Pai

Mar 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
SP
Hello All,

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

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

}
to:

if (txt_Imm_Main_Other.Text == "5172")
{
txt_Imm_Main_Other.Text = "";
txt_Imm_Main_Other.Visible = true;
}
else
{
txt_Imm_Main_Other.Visible = false;
}

and it worked

Thanks,
Pai

Mar 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.