动态增加多行数据并保存到数据库
如:
增加一行 删除一行 保存
产品ID 产品编码 数量 单价 总价
1 001 100 20 2000
2 002 50 16 800
当点击“增加一行”时,表格下面增加一空白行,可无限增加下去。并在多个空白行里输入数据,点击“保存”将所有新增数据保存到数据库中。
用JS 在前台实现,在后台保存数据。或在GridView 中实现这中功能。我只能给100分,不够我再开贴!请大家帮帮忙!
如:
增加一行 删除一行 保存
产品ID 产品编码 数量 单价 总价
1 001 100 20 2000
2 002 50 16 800
当点击“增加一行”时,表格下面增加一空白行,可无限增加下去。并在多个空白行里输入数据,点击“保存”将所有新增数据保存到数据库中。
用JS 在前台实现,在后台保存数据。或在GridView 中实现这中功能。我只能给100分,不够我再开贴!请大家帮帮忙!
解决方案 »
- 紧急!导出Excel时如何取消repeater中<a href的超链接?
- 找不到存储过程
- .net后台如何获得js写的cookie?急啊
- 点击datagrid表格行,现方的另一个表格动态显示数据怎么实现?
- App_Code里面的cs类引用请教
- 读取dataset里的数据
- Jmail发邮件问题,似乎不去判断发件人的用户名与密码,不知道是什么原因?
- 带参数问题
- 怎样改变webform的caption阿
- 在 ASP。NET中使用HTML控件和使用WEB控件有什么不同!!
- 请问高手一个关于GridView控件中超链问题??急
- 如何把从数据库统计出来的一个表以 柱形图 或者 线形图 饼图的形式显示下来。
js动态生成行
ajax 保存到数据库
http://www.componentart.com/webui/demos/demos_control-specific/grid/features/editing_dataClientMode/WebForm1.aspx
http://bbs.topsage.com/dispbbs_123_185486_1.html
var allCount1=1; function addGuiGe1(){
newRow=PLList1.insertRow(PLList1.rows.length);
newRow.id="tdt1";
newRow.ln=allCount1;
Input=newRow.insertCell(0);
Input.ln=allCount1;
Input.innerHTML="机构名称:<input type='text' name='guige' size='10' id='r11"+allCount1+"'disabled='disabled'><input id='11" + allCount1 + "' type='hidden' name='ahidd11' />";
Input=newRow.insertCell(1);
Input.ln=allCount1;
Input.innerHTML="类型:<input type='text' name='guige' size='5' id='r12"+allCount1+"'disabled='disabled'><input id='12" + allCount1 + "' type='hidden' name='ahidd12' />";
Input=newRow.insertCell(2);
Input.ln=allCount1;
Input.innerHTML="联系人:<input type='text' name='guige' size='5' id='r13"+allCount1+"'disabled='disabled'><input id='13" + allCount1 + "' type='hidden' name='ahidd13' />";
Input=newRow.insertCell(3);
Input.ln=allCount1;
Input.innerHTML="备注:<input type='text' name='guige' size='10' id='r14"+allCount1+"'disabled='disabled'><input id='14" + allCount1 + "' type='hidden' name='ahidd14' />";
Del=newRow.insertCell(4);
Del.ln=allCount1;
Del.onclick=delIt1;
Del.innerHTML="<input type='button' name='Button' value=' 选择 'onClick=OpenThenSetValue('项目机构frame.aspx',500,500,'Window','r11"+allCount1+"','11"+allCount1+"','r12" + allCount1+ "','12" + allCount1 + "','r13" + allCount1 + "','13" + allCount1 + "','r14" +allCount1+ "','14" + allCount1+ "') /><input type='button' name='Button1' value=' 删除 ' ln='"+allCount1+"'>";
var len=PLList1.rows.length-1;
document.getElementById("TextBox1").value=len;
allCount1++;
} function delIt1(){
line=parseInt(event.srcElement.ln,10)
if (line>0)
for (i=1;i<PLList1.rows.length;i++){
if (tdt1[i].ln==line){
PLList1.deleteRow(i)
var n=PLList1.rows.length-1;
document.getElementById("TextBox1").value=n;
}
}
} </script>你看看这个行不行
后台用Request.Form取数据
然后就是循环插入数据库了
http://www.lyyywx.com.cn
http://www.bdgxqsq.com.cn