puskar maji

puskar maji

  • NA
  • 20
  • 0

how to create multiple row at runtime?

Jan 23 2009 10:41 AM
bellow code is creating only one row in a existing table named Table1 instead i want to get 4 row each row containing 2 cell with textbox.waht i have..i am only unable to create 4 rows...plz help


int numcells = 2;
        TableRow r = new TableRow();
        for (int j = 0; j < 4; j++)
        {
            Table1.Rows.Add(r);
            for (int i = 0; i < numcells; i++)
            {
                TableCell c = new TableCell();
                TextBox textb = new TextBox();
                textb.ID = "txtR" + Table1.Rows.Count + "C" + i;

                textb.EnableViewState = true;
                c.Controls.Add(textb);
                r.Cells.Add(c);
            }
        }

Answers (3)