保存可满足的内容更改

时间:2016-08-23 13:52:00

标签: asp.net-mvc-5 contenteditable

美好的一天!我是asp.net MVC 5中的新手,正在处理一个单元格可编辑的表单,然后将其保存在数据库中,以及其他单元格的值。我已设法使用 contenteditable =" true" 使单元格可编辑。这是我的观点:



<div class="container">
    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <div class="col-lg-12">
            <div class="col-lg-6"></div>
            <div class="col-lg-6">

                <div class="form-horizontal">

                    <div class="form-group">
                        @Html.LabelFor(m => m.CUSTOMER_ID, "Customer Name", new { @class = "control-label col-md-2" })
                        <div class="col-md-10">
                            @Html.DropDownList("CUSTOMER_ID", ViewBag.CustomerName as IEnumerable<SelectListItem>, "--Select Customer--", new { @class = "form-control" })
                        </div>
                    </div>


                    <div class="form-group">
                        @Html.LabelFor(model => model.ORDER_DUE_DATE, "Due Date", htmlAttributes: new { @class = "col-lg-5" })
                        <div class="col-lg-7">
                            @Html.TextBoxFor(model => model.ORDER_DUE_DATE, "{0:yyyy-MM-dd}", new { @class = "form-control", @type = "date" })
                            @Html.ValidationMessageFor(model => model.ORDER_DUE_DATE, "", new { @class = "text-danger" })
                        </div>
                    </div>


                </div><!--form-horizontal-->



            </div>

        </div><!--col lg 12-->



        <table id="tbl_orderItems" class="table table-striped table-bordered table-hover dt-responsive nowrap" cellspacing="0">
            <thead>
                <tr>

                    <th>Item Code</th>
                    <th>Quantity</th>

                    <th>Unit</th>
                    <th>Item Description</th>
                    <th>Status</th>
                    <th>Action</th>
                </tr>
            </thead>

            @if (TempData["listOrder"] != null)
            {
                foreach (var items in TempData["listOrder"] as List<ebms.ViewModels.OrderItems>)
                {  @Html.HiddenFor(modelItem => items.Id)
                <tr>

                    <td>@items.PRODUCT_CODE</td>
                    <td contenteditable="true">@items.iQuantity</td>
                    <td>@items.MEASUREMENT_NAME</td>
                    <td>@items.ITEM_DESCRIPTION</td>
                    <td>@items.tmpStatus</td>
                    <td>
                        @Html.ActionLink("Remove", "Remove", new { id = items.Id },
                                        new { onclick = "return confirm('Are sure want to remove?');" })
                    </td>
                </tr>

                }


            }

        </table>

        <div id="menu1">
            <ul>

                <li>
                    <center><a>Select an Item</a></center>
                    <ul>
                        <li><a href='@Url.Action("Products", "Sales")'>Products </a></li>

                    </ul>
                </li>
            </ul>

        </div>





        <div class="form-group">
            <div class="col-lg-3 pull-right">
                <input type="submit" value="Create" class="btn btn-primary" />
            </div>
        </div>



    }
</div>
&#13;
&#13;
&#13;

我已将 contenteditable =&#34; true&#34; 放在数量中,因为它是应该可编辑的单元格。其中的大多数其他值都来自这种形式:enter image description here

然后将它传递给此表单,数量应该是可编辑的。 enter image description here

然后将选择客户并且订单到期日也将被放入。我的问题是,键入可编辑单元格的值不会保存到数据库中。有人可以帮助我如何正确使用 contenteditable =&#34; true&#34; 然后将其保存到数据库中?先谢谢你!

0 个答案:

没有答案