I think your 'visible' binding should be outside of your template binding like this:
<div data-bind="template: {name:'grid', foreach: Users}, visible: grid()"></div>
<div data-bind="template: {name:'list', foreach: Users}, visible: !grid()"></div>
Here's a fiddle.