Click here to Skip to main content
15,741,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I am trying to display data simply from an array to the home page. I am following a tutorial but the data is not displaying. Can anyone help me what i am doing wrong. what i have done so far is given bellow.

Index.cshtml Contains:

<pre lang="text"><table class="table table-striped table-bordered table-condensed">
        <th>First Name</th>
        <th>Last Name</th>
    <tbody data-bind="foreach: Profiles">
            <td data-bind="text: FirstName"></td>
            <td data-bind="text: LastName"></td>
            <td data-bind="text: Email"></td>
<script src="~/Scripts/Contact.js"></script>

And the view _Layout.cshtml contains:

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8" />
    <title>@ViewBag.Title - Contact manager</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />
    @RenderSection("scripts", required: false)

    <div class="container-narrow">
        <div class="masthead">
            <ul class="nav nav-pills pull-right">
            <h3 class="muted">Contact Manager</h3>
        <div id="body" class="container">
            @RenderSection("featured", required: false)
        <hr />
        <div id="footer">
            <div class="container">
                <p class="muted credit">© @DateTime.Now.Year - Design and devloped by IC.</p>


What I have tried:

Contact.js contains:

var DummyProfile = [
"ProfileId": 1,
"FirstName": "Anand",
"LastName": "Pandey",
"Email": ""
"ProfileId": 2,
"FirstName": "John",
"LastName": "Cena",
"Email": ""

var ProfilesViewModel = function () {
var self = this;
var refresh = function () {

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

ko.applyBindings(new ProfilesViewModel());
Updated 25-Jul-16 22:54pm
TechMocktail 26-Jul-16 11:27am    
Does your bundle contains knockout.mapping.js script?
Imran Chohan 26-Jul-16 11:29am    
I think no. I have pasted the code which i am using for this
Suvabrata Roy 18-Oct-16 8:29am    
This will help you :

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