public void LoadUlipSubPlans() { DataSet ds = assetBo.GetULIPSubPlans(int.Parse(ddlUlipPlans.SelectedItem.Value.ToString())); int count = ds.Tables[0].Rows.Count; LiteralControl literal = new LiteralControl(); Table tb = new Table(); TableCell tc; //Terminal.Controls.Add(tb); for (int i = 0; i < count; i++) { TableRow tr = new TableRow(); tc = new TableCell(); Label lbl = new Label(); lbl.ID = "lblTerminalId" + (i).ToString(); // lbl.ID = ds.Tables[0].Rows[i][0].ToString(); lbl.CssClass = "FieldName"; lbl.Text = ds.Tables[0].Rows[i][1].ToString(); tc.Controls.Add(lbl); tr.Cells.Add(tc); tc = new TableCell(); TextBox txtBox1 = new TextBox(); txtBox1.ID = "txtAllocationId" + i.ToString(); // txtBox1.ID = ds.Tables[0].Rows[i][0].ToString(); txtBox1.CssClass = "txtField"; tc.Controls.Add(txtBox1); tr.Cells.Add(tc); tc = new TableCell(); TextBox txtBox2 = new TextBox(); txtBox2.ID = "txtUnitsId" + i.ToString(); //txtBox2.ID = ds.Tables[0].Rows[i][0].ToString(); txtBox2.CssClass = "txtField"; tc.Controls.Add(txtBox2); tr.Cells.Add(tc); tc = new TableCell(); TextBox txtBox3 = new TextBox(); txtBox3.ID = "txtPurchasePriceId" + i.ToString(); // txtBox3.ID = ds.Tables[0].Rows[i][0].ToString(); txtBox3.CssClass = "txtField"; tc.Controls.Add(txtBox3); tr.Cells.Add(tc); tb.Rows.Add(tr); } PlaceHolder1.Controls.Add(tb); lblUnits.Visible = true; lblPurchasePrice.Visible = true; lblAllocation.Visible = true; btnSubmit.Visible = true; Session["table"] = tb; }