首页 > 代码库 > Linq使用小记之Group By
Linq使用小记之Group By
private void cmbStore_SelectedIndexChanged(object sender, EventArgs e) { DataTable vDt = ParamClass.ChargDt; var q = from b in vDt.AsEnumerable() group b by new { storeid = b["STOREID"], charg = b["charg"] } into g select new { g.Key.storeid, g.Key.charg }; if (q != null && q.Count() > 0) { for (int i = 0; i < gridPurchaseOrderDetail.Rows.Count; i++) { (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).DataSource = q.ToList(); (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).ValueMember = "charg"; (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).DisplayMember = "charg"; (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).Value = http://www.mamicode.com/q.ElementAt(0).charg; getStockNum(i); } } }
Linq使用小记之Group By
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。