动态增加多行数据并保存到数据库
如:
增加一行    删除一行   保存
产品ID 产品编码 数量 单价 总价
1 001 100 20 2000
2 002 50 16 800


当点击“增加一行”时,表格下面增加一空白行,可无限增加下去。并在多个空白行里输入数据,点击“保存”将所有新增数据保存到数据库中。
用JS 在前台实现,在后台保存数据。或在GridView 中实现这中功能。我只能给100分,不够我再开贴!请大家帮帮忙!

解决方案 »

  1.   

    用repeater + table不可以么 
     js动态生成行
    ajax 保存到数据库
      

  2.   


    http://www.componentart.com/webui/demos/demos_control-specific/grid/features/editing_dataClientMode/WebForm1.aspx
    http://bbs.topsage.com/dispbbs_123_185486_1.html
      

  3.   

    http://www.componentart.com/webui/demos/demos_control-specific/grid/programming/bare_bonesClientEditing/WebForm1.aspx
      

  4.   

    <script language="javascript">
     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>你看看这个行不行
      

  5.   

    用JS操作HTML表格
    后台用Request.Form取数据
    然后就是循环插入数据库了
      

  6.   

    http://www.xpeng.com.cn
    http://www.lyyywx.com.cn
    http://www.bdgxqsq.com.cn