title: Binding to ASP grid template field using knockoutJS after Ajax call
body: <p>I am working on a project where I succesfully made web servie calls via ajax, returned the data, and binded single line results to text boxes. However, there are cases where a field such as account, might have multiple values, and indexed in my case. I am able to hard code the returned results and bind it, but i need to do it dynamically and not hard code it because the web service call could return different number of lines depending on the data given to it. Here is some of the code:</p>
  
  <pre><code> function RetrieveEntity() {
   var pageUrl1 = "ajaxwebservicecalls.asmx/RetrieveEntity";
      $.ajax({
          type: "POST",
          url: pageUrl1,
          data: {},
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          async: false,
          success: OnretrieveSuccessCall,
          error: onretrieveFail
      });
  
  
  }
  function OnretrieveSuccessCall(msg) {
      var defaultdata = msg.d.Data;
      invoiceModel = defaultdata;
      var x = JSON.stringify(defaultdata);
      MyProject.viewModel = ko.mapping.fromJS(invoiceModel);
      ko.applyBindings(MyProject.viewModel)
  alert("hello");
  }
  </code></pre>
  
  <p>(No need to show the webservice asmx file because that part works fine)
  the returned results look similar to this:</p>
  
  <pre><code>  header1.value = "abc"
    header2.value = "efg"
  </code></pre>
  
  <p>so when i bind it to a text box, all i have to do is call data-bind="value: header1.value" and that works fine</p>
  
  <p>However, multiple line results are returned in an indexed formart as follows:</p>
  
  <pre><code>Header1[(value1=xxx,value2=yyyy,value3=zzz),(value1=ddd,value2=fff,value3=fgghg)] 
  </code></pre>
  
  <p>so when i databind it (hardcoded value), i used </p>
  
  <pre><code>data-bind="value:header1()[0].value1" 
  </code></pre>
  
  <p>and that returns "xxx" </p>
  
  <p>my problem is if i want to return all answers for value1 (xxx, ddd) and bind them on a grid. I used a template field grid, and placed a text box inside it, and tried to retrieve the value using a hardcoded index it worked. But when i wanted to return all possible values (using #index or $data0 it didn't work. I'm not sure how to use it, and if it's even possible to an ASP bind a gridview using knokcoutjs. please help me out. Below is the HTMl code (i will show one gridview field only, and i'm using the hardcoded index that is working).</p>
  
  <pre><code> &lt;asp:GridView ID="GridView2" runat="server"AllowPaging="True"AutoGenerateColumns="False"&gt;    
   &lt;Columns&gt;
   &lt;asp:TemplateField HeaderText="Account" SortExpression="Account" &gt;
    &lt;ItemTemplate&gt;
      &lt;asp:TextBox ID="Account" runat="server" MaxLength="60" ReadOnly="true" 
       TabIndex="-1" Style="width: 250px" data-bind="value:APInvoiceItems()[0].Accountnumber"/&gt;
                  &lt;/ItemTemplate&gt;
           &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  &lt;button onclick=" RetrieveEntity()"&gt; Update &lt;/button&gt;
  </code></pre>
  
  <p>the account number at index zero is returned from the above code. How to return index 1, 2 and so on?
  All help is greatly appreciated. Thank you in advance!!</p>