i have a linq result as var & query as following
var groups = myDataTable.AsEnumerable()
.GroupBy(r => r.Field<string>("X"))
.Select(g => new { Name = g.Key,Count=g.Count() });
I want to bind the result to datagridview.
Please suggest
Thanks
Try the following:
dataGridView.DataSource = groups.ToList();
updated
Have you tried this way?
yourGridView.DataSource=groups.ToList();
yourGridView.DataBind();
for WinForm apps only do this:
yourGridView.DataSource=groups.ToList();
Try this
var groups = (myDataTable.AsEnumerable()
.GroupBy(r => r.Field<string>("X"))
.Select(g => new { Name = g.Key,Count=g.Count() })).ToList();
gridview1.DataSource=groups;
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.