Dynamic Table creation in C#

Arul44ece
Posted by Arul44ece under C# category on | Points: 40 | Views : 1813
The below code used to create text box and table dynamically.

Table tb = new Table();

tb.BorderWidth = Unit.Pixel(5);

for (int i = 1; i <= Convert.ToInt32(TextBox1.Text ); i++)

{

TableRow tr = new TableRow();

for (int j = 1; j <= 3; j++)

{

TableCell td = new TableCell();

TextBox c_text = new TextBox();

c_text.Visible = true;

c_text.Text = "R"+i.ToString()+j.ToString();

c_text.ID = "R" + i.ToString() + j.ToString();

td.Controls.Add(c_text);

tr.Cells.Add(td);

tb.Rows.Add(tr);

form1.Controls.Add(tb);

}

}

Comments or Responses

Posted by: T.Saravanan on: 10/4/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Kindly post your code inside the code tag.

Login to post response