用LINQ查询填充DropDownList

时间:2018-09-25 15:46:25

标签: c# asp.net linq

我想在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();

1 个答案:

答案 0 :(得分:0)

投影Family而不是匿名对象:

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