2个回答
展开全部
1.自定义数据源
int[] a = { 1, 2, 3, 4, 5 };
var sQuery = from t in a
where t > 2
select t;
ddlLINQ.DataSource = sQuery.ToList();
ddlLINQ.DataBind();
2.从数据库中获取数据
var sQuery = from t in table
where t.id > 2
select new{t.id,t.name};
ddlLINQ.DataSource = sQuery.ToList();
ddlLINQ.DataTextField = "name";
ddlLINQ.DataValueFile = "id";
ddlLINQ.DataBind();
没测试 但想原理是这样的! 希望可以帮到你!
int[] a = { 1, 2, 3, 4, 5 };
var sQuery = from t in a
where t > 2
select t;
ddlLINQ.DataSource = sQuery.ToList();
ddlLINQ.DataBind();
2.从数据库中获取数据
var sQuery = from t in table
where t.id > 2
select new{t.id,t.name};
ddlLINQ.DataSource = sQuery.ToList();
ddlLINQ.DataTextField = "name";
ddlLINQ.DataValueFile = "id";
ddlLINQ.DataBind();
没测试 但想原理是这样的! 希望可以帮到你!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询