private bool NewMenuItem(string itemID) {//need to fix this... MenuItem newItem = new MenuItem(); //all new records will be give a negative int autoid... //when they are updated then sql will generate one for them overiding this set value... //it will allow us to give uniqueness to the tempory new records... //Before they are updated to the entity and given an autoid... //we use a negative number and keep subtracting by 1 for each new item added... //This will allow it to alwasy be unique and never interfere with SQL's positive autoid... _newMenuItemAutoId = _newMenuItemAutoId - 1; newItem.AutoID = _newMenuItemAutoId; newItem.MenuItemID = itemID; newItem.CompanyID = ClientSessionSingleton.Instance.CompanyID; //new items will be added to selected item newItem.ParentMenuID = SelectedMenuItem.MenuItemID; //add it to the repository list MenuItemList.Add(newItem); _serviceAgent.AddToMenuItemRepository(newItem); //add it to the treeviewList NestedMenuItem newNestedItem = new NestedMenuItem(newItem); newNestedItem.IsValid = 1; newNestedItem.NotValidMessage = "New Record Key Field/s Are Required."; SelectedMenuItem.Children.Add(newNestedItem); AllowEdit = true; Dirty = false; return(true); }