protected void BtnInsert_Click(object sender, EventArgs e) { //get listview item chk foreach (ListViewDataItem item in ListViewHakAkses.Items) { CheckBox chkSelect = (CheckBox)item.FindControl("ChkIDMem"); if (chkSelect != null) { int ID = Convert.ToInt32(chkSelect.Attributes["value"]); if (chkSelect.Checked && !this.ID_Mem.Contains(ID)) { this.ID_Mem.Add(ID); } else if (!chkSelect.Checked && this.ID_Mem.Contains(ID)) { this.ID_Mem.Remove(ID); } } } //insert value Koneksi cn = new Koneksi(); foreach (int item in ID_Mem) { Hasil = cn.KelasKoneksi_InsertHakAkses(item, Convert.ToInt32(DropDownListHakAkses.SelectedValue)); //Response.Write("<script language='javascript'>window.alert('Berhasil Insert Data');</script>"); } if (Hasil == "OK") { ListViewHakAkses.DataBind(); Response.Write("<script language='javascript'>window.alert('Berhasil Insert Data');</script>"); } else { ListViewHakAkses.DataBind(); Response.Write("<script language='javascript'>window.alert('Terdapat Error Insert Data : " + Hasil + "');</script>"); } }