Form top
Asp.net background code implementation click to dynamically Add a row of table
It can be implemented by session. I am working on a logistics system to increase the departure time of vehicles.
First, initialize session ["str"] = "";
Write in the click event of this button
Session ["str"] = string. concat (session ["str"]. tostring (), "<tr> <TD> <inputtype = \" text \ "name = \" (here, you can get a name for it. Using request ["name"]. tostring automatically retrieves values in textbox separated by commas. You can try it yourself .) \ "Style = \" width: 156px \ "> </TD> </tr> ");
(String. Concat (string1, string2) is used to connect string1 and string2 strings, that is, each time a new row is added after an existing row .)
Then, use <% = session ["str"] %> In the front-end aspx file to display these rows, place it in the middle of your <Table> and </table> to Add rows to the table.
You can also have naming rules. They can also use the same name, for example, AA, then name = \ "AA \", so that you can use request ["AA"] to retrieve a batch of values. Or you want to name it aa0, aa1, Aa2 ......, You can define a session ["I"] = 0, and then in the previous sectionCodeName = \ "AA \" + session ["I"]. tostring () session ["I"] = session ["I"] + 1; then you can.