【问题标题】:AspNet Two Tables on a ViewAspNet 视图上的两个表
【发布时间】:2017-05-30 19:42:11
【问题描述】:

我正在构建一个 ASP.Net MVC 4 应用程序,我需要使用两个表。

示例:

我有数据库中的产品的第一个表,当我点击绿色按钮时,项目需要在表内向下,我可以选择我想要的任何项目,当我完成时,我点击保存以注册“销售”,但我不能这样做。

我的问题:

如何使用按钮从第一个表中获取项目值并传递给控制器​​?

我可以使用 JavaScript 放在另一张桌子上,然后当我完成后发送到控制器吗?

我只想将数据从表 1 传递到表 2!

我的代码:

表 1

    <!--Table to display registered products-->
<table class="table table-condensed table-hover">
    <thead>
        <tr>
            <th>CODIGO</th>
            <th>NOME</th>
            <th>PRECO</th>
            <th>QUANTIDADE</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @if (Model != null)
        {
            foreach (var product in Model)
            {
                <tr>
                    <td>@Html.DisplayFor(model => product.idProduct)</td>
                    <td>@Html.DisplayFor(model => product.nameProduct)</td>
                    <td><p>R$@Html.DisplayFor(model => product.pricesaleProduct)</p></td>
                    <td><input type="text" class="form-control bfh-number" value="1"></td>
                    <!--Here i want get values to put on other table Or send to a controller-->
                    <td>
                        <a class="btn btn-success"><span class="glyphicon glyphicon-plus"> Adicionar</span></a>
                    </td>
                </tr>
            }
        }
    </tbody>
</table>

表 2:

<!--Table to display selected products-->
<table class="table table-condensed table-hover">
    <thead>
        <tr>
            <th>CODIGO</th>
            <th>NOME</th>
            <th>PRECO</th>
            <th>QUANTIDADE</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</table>

【问题讨论】:

    标签: javascript mysql asp.net twitter-bootstrap asp.net-mvc-4


    【解决方案1】:

    您希望将底部表格创建为 部分视图,然后在单击按钮时通过 AJAX 加载它...有很多示例,就像这样:

    http://www.binaryintellect.net/articles/218ca630-ba50-48fe-af6e-6f754b5894aa.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      • 2013-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多