code สร้างตาราง รับค่าจาก textbox
protected void Button1_Click(object sender, EventArgs e)
{
int numrows;
int numcells;
int i = 0;
int j = 0;
int row = 0;
HtmlTableRow r;
HtmlTableCell c;
numrows = Convert.ToInt32(TextBox1.Text);
numcells = Convert.ToInt32(TextBox2.Text);
status = 0;
for (j = 0; j <= numrows - 1; j++)
{
r = new HtmlTableRow();
if (row % 2 != 0)
{
r.BgColor = "Gainsboro";
}
row++;
for (i = 0; i <= numcells - 1; i++)
{
c = new HtmlTableCell();
c.Controls.Add(new LiteralControl("row" + (j+1) + ",col" + (i+1)));
//c.Controls.Add(new LiteralControl("Idle"));
r.Cells.Add(c);
}
Table1.Rows.Add(r);
}
}