Click here to Skip to main content
14,875,846 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I stucked in proper way of binding value. Suppose I have model:
C#
public class PersonViewModel
    {
        public int CityID { get; set; }
        public List<City> CityList { get; set; }

        public int PersonID { get; set; }
        public string Name { get; set; }
        public string SureName { get; set; }
    }


In view for this model I want to have button when on click modal will pop up, or list show up with list of possible person. When I choose any row fields from model should fill :
C#
public int PersonID { get; set; }
public string Name { get; set; }
public string SureName { get; set; }


Everything should work with ajax. For now I have idea do fill some "div" with list of Persons with ajax method, and after select row fill fields with value by jquery like
C#
$('#PersonID').val($('#selected_PersonID').val())


But this apporach is not elegant.

Question is, how to bind model value from dynamically populated list?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900