Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
[^]
HTML
<table ID="tblUploadExcel">
@{int i = 0;}
@foreach (var p in Model)
{
	<tr>
		<td><label id="WorkItemId_@i">@p.WorkItemId</label></td>
		<td>
			@Html.TextBox("EstimatedDateTime", null, new { @id = "EstimatedDateTime_" + i })
		</td>
		<td>@Html.DropDownList("AssignedTo_" + i, (IEnumerable<SelectListItem>)@p.Uinfo, "--Select Name--")</td>
	</tr>
	i++;
}
  </table>

JavaScript
<script>
    function Save() {
                
                var rowCount = $('#tblUploadExcel').dataTable().fnGetData().length;

               
                //write jquery logic to read table data and push into list and then send to controller action,
                //read data in controller action for storing into db
                var workList = [];
                for (var i = 0; i <= rowCount - 1; i++) {
                    var WorkItemDetails = {};
                    WorkItemDetails["WorkItemId"] = $("#WorkItemId_" + i).text();
                    WorkItemDetails["EstimatedDateTime"] = $("#EstimatedDateTime_" + i).val();
					WorkItemDetails["AssignedTo"] = ($("#AssignedTo_" + i).val());
                    workList.push(WorkItemDetails);
                }

                var workinfo = JSON.stringify(workList);
                var info = { "prodsjson": workinfo };
                //send ajax request
                $.ajax({
                    type: "POST",
                    //  traditional: true,
                    //async: false,
                    cache: false,
                    url: '/Admin/WorkDetais',
                    //context: document.body,
                    data: info,
                    success: function (result) {
                        
                    },
                    error: function (xhr) {
                        //debugger;
                        console.log(xhr.responseText);
                        alert("Error has occurred..");
                    }<
                });
            }
        </script>



I am using  "Bootstrap-Table-With-Sorting-Searching-and-Paging" using
<a href="http://www.codeproject.com/Tips/823490/Bootstrap-Table-With-Sorting-Searching-and-Paging">This artical</a>  




Issue:- I have 20 recodes in my dataTable and trying to Save.But inputs and labels losing-values-when-paging 

Any Idea to make it work


What I have tried:

I was Trying to remove Bootstrap. then its working fine but i need both bootstrap and save all values with single submit
Posted
Updated 15-Apr-16 22:27pm
v6

1 solution

You can save table into hidden variable then do paging. when you want save table values call table from hidden variable
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900