如何在包含三个用于用户输入的asp.net服务器控件的表中动态添加行(how to add rows dynamically in the table containing three asp.net server controls for user input)

   IT问题网   2021-01-21 00:00:00

问 题




一个有5行3列的表,

每行包含3个用于用户输入的asp.net服务器控件文本框。



i希望在buttonclick上动态添加更多行,而每个新行包含3个文本框供用户输入。



i am不是客户端的专家,目前我通过隐藏行(10个额外的行)并在按钮点击上逐个显示静态工作,但这不是有效的工作,也有局限性。



感谢提前。



zain ul abedin

解决方案

试试这个简单html和javascript代码。希望它可以帮助您解决问题。



 lt;   html  gt;  
lt; head gt;
lt; script type =" text / javascript" gt;
function insrow(){
var tbl = document .getelementbyid(' mytable');
var len = tbl.rows.length;
var row = tbl.insertrow(len);
for var i = 0 ; ilt; tbl.rows [ 0 ]。cells.length-1; i ++){
row.insertcell(i).innerhtml = " lt; input type = textgt;";
}
row.insertcell(tbl.rows [ 0 ]。cells.length-1).innerhtml = ' lt; input type ="button"onclick ="delrow(this)"value ="delete row"gt;';
}

function delrow(obj){
var row = obj;
while (row.nodename.tolowercase()!= ' tr'){
row = row.parentnode;
}
var tbl = document .getelementbyid(' mytable');
tbl.deleterow(row.rowindex);

}
lt; / script gt;
lt; / head gt;
lt; body gt;
lt; table id =" mytable" border =" 1" width =" 50%" cellspacing =" 0" cellpadding =" 2" gt;
lt; tr gt;
lt; td gt; 单元格1 lt; / td gt;
lt ; td gt; 单元格2 lt; / td gt;
l t; td gt; 单元格3 lt; ; / td gt;
lt; td gt; lt; input type =" 按钮" onclick =" insrow()" value =" 插入行" gt; lt; / td gt;
lt; / tr gt;
lt; / table gt; lt; br gt;
lt; 表格 gt;


lt ; / form gt;
lt; / body gt;
lt; / html gt;
lt; / br gt; lt; / html gt;




谢谢amp;此致,

niral soni

标签:何在包含包括包孕蕴含三个用于用户输入服务器



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

如何将string []数组值分配给cookie(How to assign a string[] array values to a cookie)

problem i have a string array and it is filling by databa ...

在基本MSI项目中从InstallShield显示消息“安装程序需要64位处理器”(Show message “Setup requires a 64Bit processor” from InstallShield in basic MSI project)

problem i am using installshield 11 and creat ...

c ++编程语言(c++ programming language)

problem hello all, i am looking to design c++ code for is ...

MySql DB(如何在部署时添加DB)(MySql DB(how to add DB at the time of deployment))

problem hello, i am going to deploy(c#.net with mysql 5.0 ...

如何为15个链接按钮单击事件实现相同的代码(How to implement same code for 15 linkbutton click events)

problem hi, i want to bind a tree in horizon ...

在数据网格中更改字段的名称(change field's name in a datagrid)

problem how can i change name of the each header columns ...

使用多个mdi表单(working with mutiple mdi forms)

problem hello i have a c sharp application, which contai ...

更改Html对象Zindex(Change Html Object Zindex)

problem hi all i have an object in my page. i ...

GDI +中发生一般错误的问题。(problem with A generic error occurred in GDI+.)

problem hi all when i want save image from fileupload fa ...

编写非肥皂网服务(Writing Non soap web service)

problem please let me know how to write a non ...

在asp.net和c#中动态创建按钮(Dynamically created button in asp.net and c#)

problem hi, i am creating online examination ...

文件上传问题,找不到文件(File Upload problem, file not found)

problem hi, from my asp.net form, i am trying ...

请在下拉列表中解决错误(please solve error in dropdown list)

problem please solve the error i have 2 dropdownlist. in ...

更改属性上的ReadOnly属性不起作用(Change ReadOnly attribute on property doesn't work)

problem i''ve tried to change a readonly attr ...

我如何分割我的表格(how do i split my form)

problem ok i want to split my form in half so on the left ...

将templatefield动态添加到gridview(adding templatefield dynamically to gridview)

problem give the tutorial to add template field, controls ...

在c#的帮助下导出pdf文件(Export pdf File with the help of c#)

problem how to convert more then one pdf file ...

计算中间日期并在gridview中显示它(calculate inbetween date and show it in gridview)

problem hello friends, by using date time pi ...

为它的学生项目(Project for an it student)

problem hi, i m an bsc it student ,as many of you will kn ...

单击更改图标通知(Change Icon Notify on Click)

problem is possible changer notifyicon1 on click the prog ...