Dynamically create a table, row(tr) and cell(td) in C#

Create a table dynamically

Table submitTable = new Table();

Create a row(tr) dynamically

TableRow row = new TableRow();

Create a cell(td) dynamically

TableCell cell = new TableCell(); 

Add a button in a cell :

cell.Controls.Add(this.BuildTestButton());

Add cell in a row : 

row.Cells.Add(cell); 

Add row in a table :

submitTable.Rows.Add(row);

protected virtual Button BuildTestButton()

 {

        Button button = new Button();

        button.Width = 120;

        button.Text = "Test";

        button.Click += new EventHandler(this.OnTestButtonClick);

        return button;

 }

 protected virtual void OnTestButtonClick(object sender, EventArgs e)

 {

                //do your code here.

 }