I have a standard HTML <table inside an ASP:Panel control.
Inside this HTML table is a <TR row
And inside this TR row are severale tables.
<asp:panel ID="PanelPreStart" runat="server" Visible="false" Enabled="false" Width="500px" >
<table runat="server" id="tblPreStart">
...
...
<tr id="trRiskMgt" runat="server" visible="false">
<td colspan="2">
<strong><big>** RISK MANAGEMENT **</big></strong>
<br /><br />
<table id="tblHOC_MON" runat="server" visible="false">
..
..
</table>
<br />
<table id="tblRMP_TUE" runat="server" visible="false" style="width: 100%; height: 114px; color: black; background-color: white;">
<tr>
...
... etc
How do I iterate through the trRiskMgt row to get to all the tables (tblHOC_MON, etc)?
I've tried this but it does not work. I get this error:
CS1579: foreach statement cannot operate on variables of type 'System.Web.UI.HtmlControls.HtmlTableRow' because 'System.Web.UI.HtmlControls.HtmlTableRow' does not contain a public definition for 'GetEnumerator'
foreach (HtmlTableRow trow in trRiskMgt)
{
foreach (HtmlTable tbl in trow.Cells)
{
foreach (HtmlTableRow row in tbl.Controls)
{
foreach (HtmlTableCell cell in row.Cells)
{
foreach (Control ctrl in cell.Controls)
{
//CONTROL IS TEXBOXT: DISABLE CONTROL (NOT HIDE!)
if (ctrl is TextBox)
{
TextBox txt = (TextBox)ctrl;
txt.Enabled = wsDisable;
}
}
}
}
}
}
Ideas for both JavaScript and C# code behind appreciated.
Thank you
[UPDATE] I've managed to get around it by hardcoding one of the above tables into the code...
foreach (HtmlTableRow row in tblHOC_MON.Rows)
{
foreach (HtmlTableCell cell in row.Cells)
{
foreach (Control ctrl in cell.Controls)
{
//CONTROL IS TEXBOXT: EXTRACT VALUES//
if (ctrl is TextBox)
{
TextBox txt = (TextBox)ctrl;
txt.Enabled = false;
}
}
}
}
This is obviously not ideal, as I will need to repeat this code multiple times for every table in the TR row.
But it will do for now.
runat="server"on all the tags you are trying to access from C#.<td colspan="2">see?