在ASP.NET中动态添加/删除表行 [英] Dynamically Add/Remove table rows in ASP.NET

查看:131
本文介绍了在ASP.NET中动态添加/删除表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何使用asp.net从后端(在C#中)通过单击按钮触发动态地添加和删除表中的行吗?

Does anyone know how to dynamically add and remove rows in a table triggered by a button click from the backend (in c#) using asp.net?

这是用javascript完成的方式,在asp.net框架中有什么方法可以做到这一点?

Here's how it might be done in javascript, is there any way to do this in the asp.net framework?

http://viralpatel.net/blogs/2009/03/dynamically-add-remove-rows-in-html-table-using-javascript.html

推荐答案

从后面的代码构建表.您将能够以这种方式做任何您想做的事情.诸如此类,不确定类名:

Build your table from the code behind. You will be able to do whatever you want that way. something like that, not sure about the class names:

var table = new Table();
var row = new TableRow();
table.Controls.Add(row);
var cell = new TableCell();
row.Controls.Add(cell);
page.Controls.Add(table);

这篇关于在ASP.NET中动态添加/删除表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆