How to dynamically add rows to a table in ASP.NET?

前端 未结 10 1012
谎友^
谎友^ 2020-12-23 22:20

So today I started learning ASP.NET. Unfortunately I haven\'t found any good tutorials online, and I can\'t afford to buy books at the moment, so I\'ve had to create a ASP.N

10条回答
  •  眼角桃花
    2020-12-23 22:57

    ASP.NET WebForms doesn't work this way. What you have above is just normal HTML, so ASP.NET isn't going to give you any facility to add/remove items. What you'll want to do is use a Repeater control, or possibly a GridView. These controls will be available in the code-behind. For example, the Repeater would expose an "Items" property upon which you can add new items (rows). In the code-front (the .aspx file) you'd provide an ItemTemplate that stubs out what the body rows would look like. There are plenty of tutorials on the web for repeaters, so I suggest you google that to obtain further information.

提交回复
热议问题