Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have the following problem. I'm developing web application on asp.net mvc and using KnockoutJS in one of views. I have the following viewmodel

public class ExampleViewModel 
{
    public IEnumerable<Element> ElementsList { get; set; }
}

class Element
{
    public bool Required {get;set;}
}

option Required must be set with dropdown list. I have the following block code in view

<div data-bind="foreach: ElementsList">
    <select data-bind="attr: { name: 'ElementsList[' + $index() + '].Required' }, value: Required">
        <option value="true">Yes</option>
        <option value="false">No</option>
    </select>
</div>

when I select Yes or No from drop down and submit form I have appropriate value saved in database, but when I open this view in browser after that all values in drop down list are 'Yes'. Despite the fact that when I open view and debug it I can see with Quick Watch, that each value from ElementsList has correct value of Required option ('Yes' or 'No'), all dropdown lists have a value 'Yes'.

share|improve this question
2  
You're most likely experiencing this issue. – Jeroen May 13 at 16:59
thank you!!! that was useful – anykey3 May 13 at 18:15

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.