PHP vs ASP.NET Part 3
Custom tables with hidden values
from
JoeUser Forums
And so the series continues. This time with what is probably a more substantial problem than in the first or second parts of this set. In summary, what I've learned so far from the feedback is that ASP.NET resources are sadly lacking by comparison to PHP, and as a result the "simple" workarounds in ASP.NET are largely hidden from the novice programmer. This is the only avenue through which I've been able to get any help so I'm once again appealing to the greater knowledge of the Stardock community to save me from the darkness of ignorance! 
The Problem:
I have a table of items that I want to display based on variables passed to the page from a previous form. Here's a quick example of a table for purposes of discussion...
I want to be able to hide/reveal any given item (and all items underneath it if necessary) if certain conditions aren't met. For example lets say Item 1 under the first Category Heading needs to be hidden. Items 2 and 3 should still display. Also, if Section Heading 2 is invisible, everything underneath it should be invisible too.
The PHP Way
If I was doing this in php, I'd have the code with the IF statements nesteled within the table itself. This would be a bit messy to maintain, but it would work. The other way I could do it is construct the entire table within the PHP code somewhere else, and then just display the variable on the page. Either way, it would be pretty simple but difficult to maintain in the long-run. I could clean it up by giving each item a variable name and then construct the larger string by piecing together variables.
The ASP.NET Way
I don't know how to properly do this. As it stands now I'm constructing ALL of my page HTML code within the C# script header and then just outputting the resultant string <%=StringVar%> within the body area. Like I said above, this is a very messy way to do it. I know there are ways to use the ASP.NET Table controls to have the entire table with all possible results setup and then just toggle which items and rows you want to make visible or not. However all of my searching and reading has kept pointing me towards manipulating table data from a database, or just how to construct an ASP.NET table, but not how to on the fly toggle content visible or invisible.
Is there a simple way to do this? I would much rather have the table built and then just toggle rows on and off as I need to, it would make everything so much more maintainable.
The Problem:
I have a table of items that I want to display based on variables passed to the page from a previous form. Here's a quick example of a table for purposes of discussion...
| Section Heading | ||
| Category Heading | ||
| Item 1 | ||
| Item 2 | ||
| Item 3 | ||
| Category Heading | ||
| Item 1 | ||
| Item 2 | ||
| Section Heading | ||
| .... |
I want to be able to hide/reveal any given item (and all items underneath it if necessary) if certain conditions aren't met. For example lets say Item 1 under the first Category Heading needs to be hidden. Items 2 and 3 should still display. Also, if Section Heading 2 is invisible, everything underneath it should be invisible too.
The PHP Way
If I was doing this in php, I'd have the code with the IF statements nesteled within the table itself. This would be a bit messy to maintain, but it would work. The other way I could do it is construct the entire table within the PHP code somewhere else, and then just display the variable on the page. Either way, it would be pretty simple but difficult to maintain in the long-run. I could clean it up by giving each item a variable name and then construct the larger string by piecing together variables.
The ASP.NET Way
I don't know how to properly do this. As it stands now I'm constructing ALL of my page HTML code within the C# script header and then just outputting the resultant string <%=StringVar%> within the body area. Like I said above, this is a very messy way to do it. I know there are ways to use the ASP.NET Table controls to have the entire table with all possible results setup and then just toggle which items and rows you want to make visible or not. However all of my searching and reading has kept pointing me towards manipulating table data from a database, or just how to construct an ASP.NET table, but not how to on the fly toggle content visible or invisible.
Is there a simple way to do this? I would much rather have the table built and then just toggle rows on and off as I need to, it would make everything so much more maintainable.
Most difficulty in programming is not caused by the language itself but knowing how to approach problem solving from a programming perspective. IDEs or even languages do not make a good programmer.