C# – Creating a dynamic table

cdynamicnetvisual studio 2010

I'm working with C# to develop my skills. I am trying a tutorial that I have found online: http://geekswithblogs.net/dotNETvinz/archive/2009/03/17/dynamically-adding-textbox-control-to-aspnet-table.aspx but when I try the code and add the Generate table method it tells me that the type or the namespace name for Table table = new Table(); could not be found.. does anyone know what namespace I should use for this. This is the rest of the code:

  private void GenerateTable(int colsCount, int rowsCount)
        {
            //Creat the Table and Add it to the Page
            Table table = new Table();
            table.ID = "Table1";
            Page.Form.Controls.Add(table);
            // Now iterate through the table and add your controls 
            for (int i = 0; i < rowsCount; i++)
            {
                TableRow row = new TableRow();
                for (int j = 0; j < colsCount; j++)
                {
                    TableCell cell = new TableCell();
                    TextBox tb = new TextBox();

                    // Set a unique ID for each TextBox added
                    tb.ID = "TextBoxRow_" + i + "Col_" + j;

                    // Add the control to the TableCell
                    cell.Controls.Add(tb);
                    // Add the TableCell to the TableRow
                    row.Cells.Add(cell);
                }
                // Add the TableRow to the Table
                table.Rows.Add(row);
            }
        }

any help would be much appreciated thanks

Best Answer

Make sure that you are importing the namespace for table MSDN Ref

is there a

using System.Web.UI.WebControls;

at the top of your file?