Create Dynamic Table With Given Row and Column Values from User Input

You Can Create Dynamic Table By Using User Input Value . First, Create a Web Page and Add following Control,

1) Label -> Assigns Text Property to "Enter Value"
2) TextBox -> To Get User Input
3) Label -> To Display Error Messages.
4) Command Button -> To invoke Click_Event()

5) Panel -> To Contain Table.
6) Table -> Placed Inside of Panel 

And Add following Codings in Button Click Event()

  protected void Button1_Click(object sender, EventArgs e)
    {

        // Total number of rows.
        int rowCnt;
        // Current row count.
        int rowCtr;
        // Total number of cells per row (columns).
        int cellCtr;
        // Current cell counter
        int cellCnt;

        if (int.TryParse(this.TextBox1.Text.Trim(), out rowCnt) && int.TryParse(this.TextBox1.Text.Trim(), out cellCnt))
        {
            TableRow tRow;
            for (rowCtr = 1; rowCtr <= rowCnt; rowCtr++)
            {
                // Create new row and add it to the table.
                tRow = new TableRow();
                this.Table1.Rows.Add(tRow);
                for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
                {
                    // Create a new cell and add it to the row.
                    TableCell tCell = new TableCell();
                    tCell.Text = "Row " + rowCtr + ", Cell " + cellCtr;
                    tRow.Cells.Add(tCell);
                }
            }
        }
        else
        {
            this.Label2.Text = "Invalid Input";
        }
       
    }

Run Your Web Application, Enter Value in Text Box, then Click Command Button, You will get Output page Like This



Thank You