Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have not actually tried this but it looks like any of <a href="http://rachelappel.com/ajax/asp-net-4-0-roadmap-ajax/" rel="nofollow noreferrer">these</a> <a href="http://www.pluralsight.com/main/whitepapers/ClientDataBindingAjax4.aspx" rel="nofollow noreferrer">three</a> <a href="http://blogs.visoftinc.com/archive/2009/04/28/ASP.NET-4.0-AJAX-Preview-4-Client-Templates.aspx" rel="nofollow noreferrer">links</a> blog post could help. All the examples show binding to lists of data. Maybe something like this:</p> <p><strong>* Sample not tested my VS 2010 comp is busted and is closely derived from the <a href="http://blogs.visoftinc.com/archive/2009/04/28/ASP.NET-4.0-AJAX-Preview-4-Client-Templates.aspx" rel="nofollow noreferrer">third link</a> *</strong></p> <pre><code>var sampleData = [ { Value: "1", Text: "1" }, { Value: "2", Text: "2" }, ]; var select = "1"; &lt;select id="list" class="sys-template" sys:attach="dataview" dataview:data="{{ sampleData }}"&gt; &lt;option value="{{ Value }}"&gt;{{ Text }}&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Then to select the value you want (done the brute force way)</p> <pre><code>var list = document.getElementById( "list"); foreach ( var option in list.options) { if( option.value == select) { option.selected = true; break; } } </code></pre> <p>Or tweak the template to include a binding for a 'selected' option. ( Again not tested, you might not be able to perform Selected === true)</p> <pre><code>var sampleData = [ { Value: "1", Text: "1", Selected: true }, { Value: "2", Text: "2" }, ]; var select = "1"; &lt;select id="list" class="sys-template" sys:attach="dataview" dataview:data="{{ sampleData }}"&gt; &lt;option value="{{ Value }}" selected="{{ Selected === true }}"&gt;{{ Text }}&lt;/option&gt; &lt;/select&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload