/// <summary> /// Ao adicionar ids, é transferido dados de um combo para o outro. /// </summary> /// <param name="ids"></param> public void adicionarIds(string ids, bool habilitarEvento) { string[] arr = ids.Split(','); for (int i = 0; i < arr.Length; i++) { bool encontrou = false; string id = arr[i].ToString(); if (id == String.Empty) { continue; } for (int y = 0; y < this.listOptions1.Items.Count; y++) { if (this.listOptions1.Items[y].Value.Equals(id)) { this.listOptions1.Items[y].Selected = true; transferItem(this.listOptions1, this.listOptions2, false, habilitarEvento); encontrou = true; } if (encontrou) { break; } } if (!encontrou) { VsLista.Add(id); } } if (VsLista.Count > 0) { string sql = this.getMyViewState("sqlSelect"); string campo = " id "; if (sql.IndexOf("e.") > -1) { campo = " e.id "; } sql = sql.Replace("order", " and " + campo + " in ( " + strVsLista(",") + ") order "); DataTable dt_l = DataAccess.ConnAccess.fetchData(DataAccess.ConnAccess.getConn(), sql); for (int i = 0; i < dt_l.Rows.Count; i++) { DataRow dr = dt_l.Rows[i]; ListItem lsi = new ListItem(dr[this.getMyViewState("textfield")].ToString(), dr[this.getMyViewState("valuefield")].ToString()); this.listOptions2.Items.Add(lsi); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { VsLista.Clear(); } }
public void AddVsLista(Object value) { if (VsLista.Contains(value)) { return; } try { if (VsLista.Contains(int.Parse(value.ToString()))) { return; } } catch { } VsLista.Add(value); }
public void removerIds(string ids) { string[] arr = ids.Split(','); for (int i = 0; i < arr.Length; i++) { bool encontrou = false; string id = arr[i].ToString(); if (id == String.Empty) { continue; } for (int y = 0; y < this.listOptions2.Items.Count; y++) { if (this.listOptions2.Items[y].Value.Equals(id)) { this.listOptions2.Items[y].Selected = true; transferItem(this.listOptions2, this.listOptions1, false, false); encontrou = true; } if (encontrou) { break; } } for (int zz = 0; zz < VsLista.Count; zz++) { if (VsLista[zz].Equals(id)) { VsLista.RemoveAt(zz); break; } } } }