protected void OnBtnExpectAddClicked(object sender, EventArgs e) { for (int i = listExpectOriginal.Items.Count - 1; i >= 0; i--) { ListItem selectedItem = listExpectOriginal.Items[i]; if (selectedItem.Selected) { string value = selectedItem.Value; bool itemExist = false; foreach (CandidateExpectancy oldItem in SessionManager.CanExpectDesList) { if (oldItem.FunctionID.Value.ToString() == value) { itemExist = true; } } if (!itemExist) { CandidateExpectancy addedItem = new CandidateExpectancy(); addedItem.CandidateExpectancyID = -1; addedItem.FunctionID = int.Parse(value); addedItem.FunctionFam = selectedItem.Text; addedItem.Type = ddlCanExpectUnit.SelectedValue; addedItem.Group = ddlCanExpectFam.SelectedValue; SessionManager.CanExpectDesList.Add(addedItem); } } } gridCanExpectDestination.DataSource = SessionManager.CanExpectDesList; gridCanExpectDestination.DataBind(); }
private IList<CandidateExpectancy> CopyCanExpectList(IList<CandidateExpectancy> sourceList) { IList<CandidateExpectancy> result = new List<CandidateExpectancy>(); foreach (CandidateExpectancy item in sourceList) { CandidateExpectancy newItem = new CandidateExpectancy(); newItem.CandidateExpectancyID = item.CandidateExpectancyID; newItem.CandidatID = item.CandidatID; newItem.FunctionFam = item.FunctionFam; newItem.FunctionID = item.FunctionID; newItem.Group = item.Group; newItem.Type = item.Type; result.Add(newItem); } return result; }