Asp.net background code implementation click to dynamically Add a row of table

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.