Click here to Skip to main content
15,878,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have create a page that display a list of data.
.chstml file is
XML
<h2>Customer Profile Configuration </h2>

<hr />
<table class="table table-striped table-bordered table-condensed">
    <tr>
        <th>Data Field Name</th>
        <th>Display Text</th>
        <th>Is Mandatory</th>
        <th>IsActive</th>
        <th></th>
    </tr>
    <tbody data-bind="foreach: CustomerProfileConfigurations">
        <tr>
            <td class="name"><a data-bind="text: DataFieldName, click: $parent.editCustomerProfileConfiguration"></a></td>
             <td>
                <input class="input-large" data-bind='value: DisplayText' placeholder="DisplayText" />
            </td>
             <td>
                <input class="input-large" data-bind='value: IsMandatory' placeholder="IsMandatory" />
            </td>
            <td>
                <input class="input-large" data-bind='value: IsActive' placeholder="IsActive"/>
            </td>

             </tr>



    </tbody>
</table>
 <input type="button" class="btn btn-small btn-primary" value="Save Customer Profile Configuration" data-bind="click:$root.UpdateCustomerProfileConfiguration" />


<script src="~/Scripts/CustomerProfileConfigurationTest.js"></script>


and Javascript Code is

var CustomerProfileConfigurationViewModel = function () {
debugger;
var self = this;
var url = "/CustomerProfileConfiguration/GetAllCustomerProfileConfigurations";
var refresh = function () {
$.getJSON(url, {}, function (data) {
self.CustomerProfileConfigurations(data);
});
};

// Public data properties
self.CustomerProfileConfigurations = ko.observableArray([]);
// Public operations

self.UpdateCustomerProfileConfiguration= function () {

// How can I bind the page data and send for update .............



};

refresh();
};
ko.applyBindings(new CustomerProfileConfigurationViewModel());

Page is working perfectly to view data.
The problem is, How can I update list of data ?
How can i Bind list of data in java script file through saveCustomerProfileConfiguration javascript method by click on Update button and send it to manager layer for save it?
Posted
Updated 26-Oct-13 1:49am
v4

From below link show the code-sample and help you to bind the collections in KnockoutJS using "foreach" loop and "if" condition also.

http://www.code-sample.com/2013/05/foreach-in-knockoutjs-if-in-knockoutjs.html[^]
 
Share this answer
 
Comments
shyam ji 16-Aug-14 6:03am    
good one
From below link you download the sample application which will help you in implementing Knockout.js with ASP.Net

Implementing MVVM Pattern in Web Applications Using Knockout[^]
 
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