问题说明了一切,我想使用列表作为数据源,我编写了下面的代码:
var uname = DB.TBL_USAGE.Where(x => x.UName != null).ToList();
List<usage> lst = new List<usage>();
foreach (var item in DB.TBL_USAGE)
{
lst.Add(new usage { uname = item.UName, bytesout = item.Bytesout });
}
var bndngsrc = new BindingSource();
bndngsrc.DataSource = lst;
dataGridView1.DataSource = bndngsrc;
这是班级:
public class usage
{
public string uname;
public string bytesout;
}
但没有运气!
任何人都可以提供一个有效的代码吗?
答案 0 :(得分:0)
var uname = DB.TBL_USAGE.Where(x => x.UName != null).ToList();
List<usage> lst = new List<usage>();
foreach (var item in DB.TBL_USAGE)
{
lst.Add(new usage { uname = item.UName, bytesout = item.Bytesout });
}
dataGridView1.DataSource = lst ;
\