Last Updated: February 25, 2016
· petermorlion

KnockoutJS and ASP.NET Repeater

The foreach binding in Knockout is a powerful and handy binding and can be used to create tables. But sometimes you're stuck with old-school ASP.NET Repeaters to create your tables (and a lot is done server-side). The good news is you can still use Knockout, just not the foreach binding.

In fact, it's quite simple. Just use the following syntax in the ItemTemplate of your Repeater:

<tr data-bind="with: myItems()[<%# Container.ItemIndex %>]"></tr>

You can find a full explanation on my blog and a working example on GitHub.