想做数据批量提交
View :<input type="text" name="username" /><input type="text" name="password" /><input type="text" name="username" /><input type="text" name="password" /><input type="text" name="username" /><input type="text" name="password" /><input type="text" name="username" /><input type="text" name="password" /><input type="text" name="username" /><input type="text" name="password" /><input type="text" name="username" /><input type="text" name="password" />多组相同字段的数据提交(有多少组数据由用户生成的)那么在
Action 这边如何接收数据并分别做insert?

解决方案 »

  1.   

    批量插入,不是要load出来一个相同的结构吗,然后insert进行批量插入.
      

  2.   

    View:
    <% for (int i = 0; i < totalcount; i++) { %>
    <tr>
       <td>
          <%= Html.TextBox("username"+i.ToString(), "") %>
       </td>
       <td>
          <%= Html.TextBox("password"+i.ToString(),"") %>
       </td>
    </tr>
    <% } %>Action:public void BatchInsert()
    {
        
        for (int i = 0; i < totalcount; i++)
        {
             string name = "username" + i.ToString();
             string username = Request[name];
             name = "password" + i.ToString();
             string password = Request[name];
             //访问数据库,插入数据
              ......
        }}
      

  3.   

    欢迎各位加入ASP.NET MVC框架超级群!让我们共同学习、进步!QQ群号:40985466 非常乐意为大家提供一个良好的交流平台!
      

  4.   

       for (int i = 0; i < count; i++) 
        { 
            //访问数据库,插入数据 
        } 
    循环插入就是了~~