I want to add controls dynamically through code behind in the following form
lblName txtName lblSubject txtSubject btnAddNewRow/linkAddNewRow
such that btAddNewRow/linkAddNewRow generates new row at run time below the present row.
Could someone help with the best possible way.
Also Is it possible to use tags only and not table ie td th for formatting. I am using row just to be significant. I do not intend to use table rows.
please consider the prefixes as the type of control.
Thanks.
Basically if your intention is related to data processing, DataGrid and GridView would be good choices.
Dynamically add ROW instead of table are actually not much different, and I can tell that you will found it not perfectly suitable compared with DataGrid and GridView.
If you really want to dynamically add row, every time you click what ever buttons(add Row Button or whatever) page will postback and the row you just added will be disappeared.
what people would usually do is to use session to store the entire table when they create table and add row.
in Page_Load and also before they add row, they would retrieve the entire table from session. this can help keeping data in original rows.
But this could be burdensome for you to handle just about each row controls’ ID, format, style etc, and think about when you wanna deal with validation, it could be hell.
I’m not saying it’s infeasible, because I went through this.
Another easier way to do is to create a Custom Control by putting an entire row including validation, styles and other thing you need in a Custom Control then dynamically add it in Page (also need Session or ViewState to store it, same thing will happen).
Hope this could help you to reconsider your design