Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2004, 04:42 PM
Authorized User
 
Join Date: Aug 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default tables

Hi -

Does anyone know how to create dynamic tables??? For example, if I enter (into a textbox) the number 3, then a table with three rows should be generated (the columns are preset). So basically, I should be able to input any number X (max 8), then a table with X number of rows should be generated.

Can anyone help please????

rizp
 
Old August 17th, 2004, 05:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi there,

On submit request that number entered and store into a variable.

Start <table> tag before loop.
Then run a loop from 1 till that number and write
Code:
<tr><td>&nbsp;</td></tr>
that many times. Use as many "<td>&nbsp;</td>"s as needed for those number of preset columns.
End the </Table> tag after loop.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old August 26th, 2004, 04:40 PM
Authorized User
 
Join Date: Aug 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi -
Thanks - that did help, although ive changed my mind as to how i want the tables generated - now I have a drop down list - where the user can select the number of rows they would like - (in total there are 14 different combinations). How can the table be generated on selecting the choice from the list?? So if i select the number 4 - a table with 4 rows should be generated instantly (with or without having a submit button). I also want that table to contain text boxes where the user can enter information - possibly even have drop down lists. This information is then going to be held in a SQL database.

Can you be more specific as to how this table can be generated please??

Many thanks - rizp
 
Old August 27th, 2004, 01:42 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

if I were you I'd use Table objec(ASP.NET objects),dont work with <td> & <tr>
Have a look at this example
Code:
        void Page_Load(Object sender, EventArgs e) {
            // Generate rows and cells           
            int numrows = 3;
            int numcells = 2;
            for (int j=0; j<numrows; j++) {          
                TableRow r = new TableRow();
                for (int i=0; i<numcells; i++) {
                    TableCell c = new TableCell();
                    c.Controls.Add(new LiteralControl("row " + j.ToString() + ", cell " + i.ToString()));
                    r.Cells.Add(c);
                }
                Table1.Rows.Add(r);
            }
        }
--------------------------------------------
Mehdi.:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
creating tables within tables in access??? carswelljr Access 3 August 23rd, 2006 01:21 PM
Fixed tables and/or fixed bkgrnd in tables slg111875 Dreamweaver (all versions) 1 June 22nd, 2006 02:31 PM
Regarding Tables spraveens HTML Code Clinic 2 October 20th, 2003 04:46 AM
regarding tables spraveens Dreamweaver (all versions) 1 September 24th, 2003 07:21 AM
Tables andy24 Classic ASP Databases 3 July 23rd, 2003 11:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.