首页 > 解决方案 > 使用 LINQ 查询填充 DropDownList

问题描述

我想在其中查看此查询,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();

标签: c#asp.netlinq

解决方案


投影Family而不是匿名对象:

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

推荐阅读