Skip to content

Adding row dynamically inside the table

Reegan Fernando

Asked Jul 17, 2009, 11:21 AM EDT1 answer
Share
LinkedInX
Greetings to all,

I am having some issues with inserting row in the existing table. I will explain it briefly.

I am having a form with several Input controls. While retrieving data from database it have to create a input controls dynamically and store the values in that control. For that while creting a row inside the row, am getting error. I enclosed the code below.

                    TableRow trow = new TableRow();                   
                    TableCell td = new TableCell();
                    tblPlan.Rows.Add(trow);
                  
                    TableCell tdplan = new TableCell();
                    trow.Cells.Add(tdplan); //am getting error in this line.
                    System.Web.UI.HtmlControls.HtmlInputText inputplanname = new System.Web.UI.HtmlControls.HtmlInputText();
                        inputplanname.ID = "Planname";
                        inputplanname.Size = 30;
                        td.Controls.Add(inputplanname);

PLease guide me.

Thanks and Regards,

Reegan.B

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    You should create the rows and cells that match the existing table BEFORE you add it to the table.
    0