Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Please explain HtmlTableRow - does not make sense

Reply
 
Old 08-10-2009   #1 (permalink)
JP


 
 

Please explain HtmlTableRow - does not make sense

I have the below code cycle through an HTML table control that is running
server side. I have it basically search for an attribute in the TR tag I
called “right” and if the attribute is present then the visibility of the TR
tag is set to the value of the variable in question.

<table width="100%" id="tableProfile" runat="server">
<tr right=”IsTech”>
<td>
Only visible if IsTech True
</td>
</tr>
<tr right=”IsAdmin”>
<td>
Only visible if IsAdmin True
</td>
</tr>
<tr>
<td>
Notice no attribute here – should be visible
</td>
</tr>
</table>

However, it’s still hiding rows that don’t even have the attribute. I’ve
checked to make sure there isn’t an orphaned tag or anything. It hides the
first row as expected but on the next row it hides all rows

On top of that the HtmlTable.Rows collection says there are only 12 rows in
the table, but there are more then 20. I cannot find a rhyme or reason to the
behavior .NET is producing. Sometimes it says the attribute but on the next
row is say there is not attribute.

Even if I adding the visible rows to a new object:

HtmlTable NewTable = new HtmlTable
NewTable.Rows.Add(profileTable)

Then it says the enumerator of profile table has changed. How is that
possible? I didn’t add anything to profile table. I added it to a separate
copy

private void RemoveOptions(bool IsTech, bool IsAdmin, bool IsSysAdmin)
{
foreach (HtmlTableRow profileRow in ((HtmlTable)tableProfile).Rows)
{
if (profileRow.Attributes["right"] != null)
{
profileRow.Visible = profileRow.Attributes["right"].Contains("IsSys") ?
IsSysAdmin : false;
profileRow.Visible =
profileRow.Attributes["right"].Contains("IsAdmin") ? IsAdmin : false;
profileRow.Visible =
profileRow.Attributes["right"].Contains("IsTech") ? IsTech : false;
}
else
{
profileRow.Visible = true;
}
}
}

--
JP
..NET Software Developer

My System SpecsSystem Spec
Old 08-10-2009   #2 (permalink)
Scott M.


 
 

Re: Please explain HtmlTableRow - does not make sense

You are using a standard HTML table and so, it can't be accessed via server
code. If you use the ASP.NET Table Server Control, you'd be able to. Or,
you could just add runat="server" to the element in question and ad an ID to
it. Then, you'd be able to access it as an object on the server.

-Scott

"JP" <JP@xxxxxx> wrote in message
newsE328F51-74A0-4E2C-9D1C-2119FFDAEF02@xxxxxx
Quote:

>I have the below code cycle through an HTML table control that is running
> server side. I have it basically search for an attribute in the TR tag I
> called "right" and if the attribute is present then the visibility of the
> TR
> tag is set to the value of the variable in question.
>
> <table width="100%" id="tableProfile" runat="server">
> <tr right="IsTech">
> <td>
> Only visible if IsTech True
> </td>
> </tr>
> <tr right="IsAdmin">
> <td>
> Only visible if IsAdmin True
> </td>
> </tr>
> <tr>
> <td>
> Notice no attribute here - should be visible
> </td>
> </tr>
> </table>
>
> However, it's still hiding rows that don't even have the attribute. I've
> checked to make sure there isn't an orphaned tag or anything. It hides the
> first row as expected but on the next row it hides all rows
>
> On top of that the HtmlTable.Rows collection says there are only 12 rows
> in
> the table, but there are more then 20. I cannot find a rhyme or reason to
> the
> behavior .NET is producing. Sometimes it says the attribute but on the
> next
> row is say there is not attribute.
>
> Even if I adding the visible rows to a new object:
>
> HtmlTable NewTable = new HtmlTable
> NewTable.Rows.Add(profileTable)
>
> Then it says the enumerator of profile table has changed. How is that
> possible? I didn't add anything to profile table. I added it to a separate
> copy
>
> private void RemoveOptions(bool IsTech, bool IsAdmin, bool IsSysAdmin)
> {
> foreach (HtmlTableRow profileRow in ((HtmlTable)tableProfile).Rows)
> {
> if (profileRow.Attributes["right"] != null)
> {
> profileRow.Visible = profileRow.Attributes["right"].Contains("IsSys") ?
> IsSysAdmin : false;
> profileRow.Visible =
> profileRow.Attributes["right"].Contains("IsAdmin") ? IsAdmin : false;
> profileRow.Visible =
> profileRow.Attributes["right"].Contains("IsTech") ? IsTech : false;
> }
> else
> {
> profileRow.Visible = true;
> }
> }
> }
>
> --
> JP
> .NET Software Developer

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Locking up - finally narrowed it down. But does this make sense? General Discussion
Defrag from the guest OS: does it make sense? Virtual Server
does this make sense? Vista performance & maintenance
Consumers Can Make Sense of Their Dollars With Microsoft Money Essentials Vista News
Consumers Can Make Sense of Their Dollars With Microsoft Money Essentials Vista News


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46