/// <summary> /// Get Inventory Dictionary for passed category /// </summary> /// <param name="Category">Category</param> /// <returns></returns> public Dictionary<string, string> GetInventoryDictionaryByCategory(string Category) { Dictionary<string, string> list = new Dictionary<string, string>(); ItemsTableAdapter ta = new ItemsTableAdapter(); InventoryDS.ItemsDataTable dt = this.GetItemsByCategory(Category); ta.Fill(dt); foreach (InventoryDS.ItemsRow dr in dt.Rows) { list.Add(dr.itemdesc1, dr.pk.ToString()); } return list; }seemed to bypass the errors, but what was wrong with my original way?
>/// <summary> > /// returns list of items by Category > /// </summary> > /// <param name="Category">Category</param> > /// <returns></returns> > public InventoryDS.ItemsDataTable GetItemsByCategory(string Category) > { > > ItemsTableAdapter ta = new ItemsTableAdapter(); > return ta.GetItemsByCategory(Category); > } > > /// <summary> > /// Get Inventory Dictionary for passed category > /// </summary> > /// <param name="Category">Category</param> > /// <returns></returns> > public Dictionary<string, string> GetInventoryDictionaryByCategory(string Category) > { > Dictionary<string, string> list = new Dictionary<string, string>(); > > using (ItemsTableAdapter ta = new ItemsTableAdapter()) > { > > InventoryDS.ItemsDataTable dt = this.GetItemsByCategory(string Category); > > ta.Fill(dt); > > foreach (InventoryDS.ItemsRow dr in dt.Rows) > { > list.Add(dr.itemdesc1, dr.pk.ToString()); > } > } > > return list; > }