从动态列表中绑定模型中的值 [英] Bind value in model from dynamic list

查看:71
本文介绍了从动态列表中绑定模型中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我坚持正确的约束价值。假设我有模型:

I stucked in proper way of binding value. Suppose I have model:

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 :

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





一切都应该与ajax一起使用。现在我有想法用ajax方法填充一些带有人员列表的div,然后用jquery选择行填充字段,例如



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

$('#PersonID').val($('#selected_PersonID').val())





但这个apporach不优雅。



问题是,如何从动态填充的列表中绑定模型值?



But this apporach is not elegant.

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

推荐答案

' #PersonID')。val(


(< span class =code-string>' #selected_PersonID')。val())





但这个apporach并不优雅。



问题是,如何从动态填充的列表中绑定模型值?



But this apporach is not elegant.

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


这篇关于从动态列表中绑定模型中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆