为什么数据不在数据库中保存 [英] Why data is not saving in database

查看:72
本文介绍了为什么数据不在数据库中保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有桌面设计的视图,有四列有四个文本框,我已经添加了更多选项,再次重复4个文本框取决于用户。如果我点击Add More按钮,4个文本框正在重复,但是我在第二列中输入了数据未保存在db中的任何数据。



请帮帮我怎么样我将所有数据存储在db中。

下面是我的代码

Hi,

I have table designed view with four columns with four text boxes, I have given add more option to repeat 4 text boxes again depends on user. If I click on Add More button 4 text boxes are repeating but I I entered any data from in second column that data is not saving in db.

please help me How can I store all the data in db.
below is my code

<table class="table" style="font-family:Verdana; width:80%" id="table1">







 <tr>
                <td>@Html.DisplayNameFor(model => model.attendanceHolidaySerialNumber)</td>
                <td>@Html.DisplayNameFor(model => model.attendanceHolidayDateorDay)</td>
                <td>@Html.DisplayNameFor(model => model.attendanceHolidayDetails)</td>
                <td>@Html.DisplayNameFor(model => model.attendanceHolidayType)</td>                
            </tr>
<pre lang="HTML"><tr class="data-contact-person">
                <td>@Html.EditorFor(model => model.attendanceHolidaySerialNumber, new { htmlAttributes = new { @class = "form-control " } })</td>
                <td>@Html.EditorFor(model => model.attendanceHolidayDateorDay, new { htmlAttributes = new { @class = "form-control " } })</td>
                <td>@Html.EditorFor(model => model.attendanceHolidayDetails, new { htmlAttributes = new { @class = "form-control" } })</td>
                <td>@Html.EditorFor(model => model.attendanceHolidayType, new { htmlAttributes = new { @class = "form-control " } })</td>
                <td>
                    <button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>
                </td>
            </tr>






















<br />
<script type="text/javascript"><br />
<br />
    $(document).ready(function () {<br />
        $(document).on("click", ".classAdd", function () {<br />
            var rowCount = $('.data-contact-person').length + 1;<br />
            var contactdiv = '<tr class="data-contact-person">' +<br />
                '<td>@Html.EditorFor(model => model.attendanceHolidaySerialNumber, new { htmlAttributes = new { @class = "form-control " } })' + rowCount + '  </td>'+ <br />
                '<td>@Html.EditorFor(model => model.attendanceHolidayDateorDay, new { htmlAttributes = new { @class = "form-control " } })' + rowCount + '</td>'+ <br />
                '<td>@Html.EditorFor(model => model.attendanceHolidayDetails, new { htmlAttributes = new { @class = "form-control" } })' + rowCount + '</td>' +<br />
                 '<td>@Html.EditorFor(model => model.attendanceHolidayType, new { htmlAttributes = new { @class = "form-control " } })' + rowCount + '</td>' +<br />
                '<td><button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>' +<br />
                '<button type="button" id="btnDelete" class="deleteContact btn btn btn-danger btn-xs">Remove</button></td>' + <br />
                '</tr>';<br />
            $('#table1').append(contactdiv); // Adding these controls to Main table class<br />
        });<br />
    });<br />
</script><br />
<script><br />
$(document).on("click", ".deleteContact", function () {<br />
            $(this).closest("tr").remove(); // closest used to remove the respective 'tr' in which I have my controls<br />
});<br />
</script><br />





我尝试了什么:



我发布我的代码描述了问题窗口,因为我无法知道如何在你试过的窗口中发布代码的格式。



请建议我。如何将数据存储在数据库中。



谢谢



What I have tried:

I post my code in describe the problem window because I could not know the format how to post the code in what have you tried window.

Please suggest me. How do I can store the data in database.

thank you

推荐答案

(文档).ready (function(){< br />
(document).ready(function () {<br />


(document).on(click,。classAdd,function(){< br />
var rowCount =
(document).on("click", ".classAdd", function () {<br /> var rowCount =


('。data-contact-person')。length + 1;< br />
var contactdiv ='< tr class =data-contact -person>'+< br />
'< td> @ Html.EditorFor(model => model.attendanceHolidaySerialNumber,new {htmlAttributes = new {@class =form-control}} )'+ rowCount +'< / td>'< br />
'< td> @ Html.EditorFor(model => model.attendanceHolidayDateorDay,new {htmlAttributes = new {@class = form-control}})'+ rowCount +'< / td>'< br />
'< td> @ Html.EditorFor(model => model.attendanceHolidayDetails,new {htmlAttributes =新的{@class =form-con trol}})'+ rowCount +'< / td>'+< br />
'< td> @ Html.EditorFor(model => model.attendanceHolidayType,new {htmlAttributes = new {@class =form-control}})'+ rowCount +'< / td>'+< br />
'< td>< button type =buttonid =btnAddclass =btn btn-xs btn-primary classAdd> Add More< / button>'+< br />
'< button type =button id =btnDeleteclass =deleteContact btn btn btn-danger btn-xs>删除< / button>< / td>'+< br />
'< / tr>';< ; br />
('.data-contact-person').length + 1;<br /> var contactdiv = '<tr class="data-contact-person">' +<br /> '<td>@Html.EditorFor(model => model.attendanceHolidaySerialNumber, new { htmlAttributes = new { @class = "form-control " } })' + rowCount + ' </td>'+ <br /> '<td>@Html.EditorFor(model => model.attendanceHolidayDateorDay, new { htmlAttributes = new { @class = "form-control " } })' + rowCount + '</td>'+ <br /> '<td>@Html.EditorFor(model => model.attendanceHolidayDetails, new { htmlAttributes = new { @class = "form-control" } })' + rowCount + '</td>' +<br /> '<td>@Html.EditorFor(model => model.attendanceHolidayType, new { htmlAttributes = new { @class = "form-control " } })' + rowCount + '</td>' +<br /> '<td><button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>' +<br /> '<button type="button" id="btnDelete" class="deleteContact btn btn btn-danger btn-xs">Remove</button></td>' + <br /> '</tr>';<br />


这篇关于为什么数据不在数据库中保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆