Change Table size in vb.net

whiwex
whiwex used Ask the Experts™
on
I am using vb.net and I have a page that contains a table with 20 rows and a drop down list. Each row in the table contains a label and a textbox. When the page loads all the labels and text boxes are invisible. When the user selects an item from the dropdownlist the some of the labels and text boxes are populated with text an those labels and textboxes are made visible. This all works fine. The problem is when the page is first loaded the full size of the table is displayed so 20 rows of nothing is displayed. If after making a selection from the drop down list and the first three rows have their labels and textbox filled with text the other 17 rows are still displayed as blank rows. Is it possible to just display the first three rows and have the other 17 rows hidden?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
When then drop down changes (and on load) you can use the Rows property of your table to access all TableRow (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.tablerow.aspx) in the table.

The TableRow has a property called Style which is a dictionary of text attributes added to the rows style tag. You can then use the "display" attribute, setting it to "none" to hide the row, and "" (blank) to show it.

Anytime the dropdown changes, you must update the Style of the TableRows that should now be hidden or shown.

You can have a look here for an example using javascript (not exactly what you need, but still pretty explicit):
http://www.javascriptf1.com/tutorial/javascript-hide-table-row.html?page=3

Author

Commented:
Thanks used the table.rows.visible = false worked great

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial