我有下拉列表,需要从[HttpPost]
中存储的属性项中获取所有值。我的var模型接受了我List< Person>
的所有信息。
list
我的下拉列表代码:
string text=File.ReadAllText(@"...");
List< Person > model = JsonConvert.DeserializeObject< List< Person>>(text)
那么我如何将所需数据绑定到下拉列表?
答案 0 :(得分:1)
<a class="foo" href="#">
<img src="http://lorempixel.com/400/200/food/1/" />
<img src="http://lorempixel.com/400/200/food/2/" />
</a>
<style>
.foo img:last-child{display:none}
.foo:hover img:first-child{display:none}
.foo:hover img:last-child{display:inline-block}
</style>
尝试使用此
答案 1 :(得分:0)
我觉得它对你很有用
List<Person> people = GetDataFromSomewhere();
DropDownList ddl = new DropDownList();
ddl.DataTextField = "Name";
ddl.DataValueField = "Id";
ddl.DataSource = people;
ddl.DataBind();
ddl.SelectedValue = (from p in people
where p.Selected == true
select p.Id).FirstOrDefault().ToString();