private void PopulateCategories() { List <Category> categories = null; categories = CategoryBS.GetAllCategories().Where(cat => cat.IsActive && cat.CompanyId == Session.Instance.AuthUser.CompanyId).ToList(); var categorylist = new BindingList <Category>(categories); dataGridView1.DataSource = categorylist; HideUnwantedColumns(); GenerateCommonColumns(); }
private void PopulateInventory() { List <Item> records = null; records = ItemBS.GetAllItems().Where(item => item.IsActive && item.CompanyId == Session.Instance.AuthUser.CompanyId).ToList(); var categories = CategoryBS.GetAllCategories().Where(item => item.IsActive && item.CompanyId == Session.Instance.AuthUser.CompanyId).ToList(); var itemList = new BindingList <Item>(records); dataGridView1.DataSource = itemList; HideUnwantedColumns(); var itelList = (from rec in categories select new { CategoryId = rec.CategoryId, CategoryName = rec.CategoryName }).ToList().Distinct(); foreach (var item in itelList) { if (!mCategoryDict.ContainsKey(item.CategoryId)) { mCategoryDict.Add(item.CategoryId, item.CategoryName); } } //DataGridViewComboBoxCell bc = new DataGridViewComboBoxCell(); //bc.DataSource = mCategoryDict.ToArray(); //bc.ValueMember = "Key"; //bc.DisplayMember = "Value"; //DataGridViewColumn cc = new DataGridViewColumn(bc); //cc.Name = "Category"; //cc.HeaderText = "Category"; //int columnIndex = dataGridView1.Columns.Add(cc); //foreach (DataGridViewRow item in dataGridView1.Rows) //{ // item.Cells[columnIndex].Value = item.Cells["CategoryId"].Value; //} GenerateCommonColumns(); }