Hiding an HTML table row in run-time

Experts, I have the usual HTML table, and I want to hide/re-display some of its <tr> in the run-time. How do I do this?

Of course I'm asking how to do this in ASP.Net

Thanks for your time,

James
James_flAsked:
Who is Participating?
 
tusharashahConnect With a Mentor Commented:
Right click your Table & make it RunAsServer Control..

then you can simply access any row of that table in code behind liek

Table1.Rows[1].Visible = false;

-tushar
0
 
ihenryConnect With a Mentor Commented:
Add attribute runat="server" to each of TR tag you want to hide/display programmatically and in code behind just set its visible property to false/true

<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
      <TR runat="server" id="row1">
            <TD></TD>
            <TD></TD>
            <TD></TD>
      </TR>
      <TR runat="server" id="row2">
            <TD></TD>
            <TD></TD>
            <TD></TD>
      </TR>
      <TR>
            <TD></TD>
            <TD></TD>
            <TD></TD>
      </TR>
</TABLE>
'---
row1.Visible = False
row2.Visible = True
0
 
ZvonkoSystems architectCommented:
You did not state on what condition or on what user action you want the row display state to toggle.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
James_flAuthor Commented:
Points given. However, tusharashah gets most points since I tried the first solution and it didn't work unless I have the table as a server control.
0
 
James_flAuthor Commented:
Thanks btw
0
 
ihenryCommented:
Hi James

You wanted to toggle display state of some tr[s] but not all, that's why I offered you my suggestion. And I'm very sure it can work very well with your requirement. The only mistake, I guess, I didn't mention explicitly that you need to declare the two variable row1 and row2 in your class. Anyway, tushar is worth more points since you can get his solution working :o)

Cheers!
0
 
James_flAuthor Commented:
cheers ihenry, i'll try doing that. Thank you for your help :D
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.