Click here to Skip to main content
15,943,077 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
<h2>Customer Profile Configuration </h2>

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


 <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 () {
var self = this;
var url = "/CustomerProfileConfiguration/GetAllCustomerProfileConfigurations";
var refresh = function () {
$.getJSON(url, {}, function (data) {

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

self.UpdateCustomerProfileConfiguration= function () {

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


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?
Updated 26-Oct-13 1:49am

From below link show the code-sample and help you to bind the collections in KnockoutJS using "foreach" loop and "if" condition also.[^]
Share this answer
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