简体   繁体   English

用LINQ查询填充DropDownList

[英]Fill DropDownList with LINQ query

I want to view this query in DropDownList but the result will appear like this {family=jac} 我想在DropDownList查看此查询,但结果将像这样{family=jac}

var show = (from u in database.tbl_Customer
            where u.moaref == session
            select new { u.Family }).ToList();

DropDownList1.DataSource = show;
DropDownList1.DataBind();

Project the Family and not an anonymous object: 投影Family而不是匿名对象:

var show = (from u in database.tbl_Customer
            where u.moaref == session
            select u.Family).ToList();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM