Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display mutliple <table> structure using for loop

Status
Not open for further replies.
Apr 3, 2005
32
US
I have a dropdown box for the users to select how many transaction entries they want to enter. Should I program as follow:
for i=1 to intRows Step 1

<table cellpadding="2" cellspacing="1" border="0">
<tr bgcolor="#eeeeee">

<td>
<asp:textbox Width = 50 ID = "AcctUnit" Runat="server">
</asp:textbox>
</td>
<td>
<asp:textbox Width = 50 ID = "AcctNum" Runat="server">
</asp:textbox></td>
<td>
<asp:textbox Width = 100 ID = "ActivityNum" Runat="server">
</asp:textbox>
</td>
<td>
<asp:textbox Width = 75 ID = "AcctCat" Runat="server">
</asp:textbox>
</td>
</table>
next
These are empty textbox that will require users to input data...But I want it to be dynamic so users can decide how many rows they can add.

Is there a better way to do this.
 
First of all, I wouldn't use tables to position your TextBoxes (use CSS instead). Then, you can simply create the TextBox's in code (for how ever many is selected from the DDL) and add them to your page (or panel/placeholder etc).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
No need to create a new table for each row, just loop through the rows:

<table cellpadding="2" cellspacing="1" border="0">
for i=1 to intRows Step 1
<tr bgcolor="#eeeeee">
<td><asp:textbox Width = 50 ID = "AcctUnit" Runat="server" /></td>
<td><asp:textbox Width = 50 ID = "AcctNum" Runat="server" /><td>
<td><asp:textbox Width = 100 ID = "ActivityNum" Runat="server" /></td>
<td><asp:textbox Width = 75 ID = "AcctCat" Runat="server" /><td>
</tr>
next
</table>

BTW, you missed the </tr>.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top