11.6. DataView Binding

DataView binding can be carried out declaratively, programmatically, or via a mixture of the two. Let's look at declarative binding first.

11.6.1. Declarative Binding

In the first example, you will create an array of people consisting of a person's name and age and then bind it declaratively:

  1. Add the following script block in the header of your page:

    <script type="text/javascript">
    Sys.require(Sys.components.dataView);
    
    var people = [
       { Name: "Alex Mackey", Age: "28" },
       { Name: "Sharyn Mackey", Age: "35" },
       { Name: "Brett Chaney", Age: "33" },
       { Name: "Jenny Chia", Age: "24"}];
     </script>
  2. Now replace the <body> tag with the following HTML:

    <body xmlns:dataview="javascript:Sys.UI.DataView"> <div id="peopleView" class="sys-template" ...

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.