the question says it all , i want to use a list as a datasource and i wrote the code below :
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;
and this is the class :
public class usage
{
public string uname;
public string bytesout;
}
but no luck !
can any one present a code that works or correct my code ?
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 ;
\\
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.