//confirm selection to be included in stafflistprotected void ConfirmBtn_Click(object sender, EventArgs e){ int sel = 0;for (int i = 0; i < SearchLB.Items.Count; i++){if (SearchLB.Items[i].Selected == true ){sel++;//if (!ListBox1.Items.Contains(SearchLB.Items[i])) //&& ListBox1.DataValueField != ConfigurationSettings.AppSettings["STAFFID"]{SQL dbAdapter = new SQL();dbAdapter.insertStafflist(SearchLB.SelectedValue, (string)Session["userName"]); }else {MessageBox.Show("Staff already existed", "Error");}//if (ListBox1.DataValueField == ConfigurationSettings.AppSettings["STAFFID"])//else//{// MessageBox.Show("Staff already existed", "Error!");//}}}if (sel == 0){MessageBox.Show("There is no selected staff to be added.", "Error");}//generate listbox itemspopulateStafflist(); }