private void GetDati(DataGrid Ctrl) { Hashtable _HS = null; if (Session["DatiListMP"] != null) { _HS = (Hashtable)Session["DatiListMP"]; } else { return; } foreach (DataGridItem o_Litem in Ctrl.Items) { System.Web.UI.WebControls.CheckBox cb = (System.Web.UI.WebControls.CheckBox)o_Litem.Cells[2].Controls[1]; System.Web.UI.WebControls.HyperLink link = (System.Web.UI.WebControls.HyperLink)o_Litem.Cells[3].Controls[0]; if (_HS.ContainsKey(link.Text)) { cb.Checked = true; CPWRList _campi = (CPWRList)_HS[link.Text]; // WRList _campi = (WRList)_HS[link.Text]; WebControls.UserOption Opt = (WebControls.UserOption)o_Litem.Cells[9].FindControl("UserOption1"); if (_campi.stato == false) { Opt.OptChiusaSospesa.Items[0].Selected = false; Opt.OptChiusaSospesa.Items[1].Selected = true; Opt.TxtMotivoSospensione.Enabled = true; } else { Opt.OptChiusaSospesa.Items[0].Selected = true; Opt.OptChiusaSospesa.Items[1].Selected = false; } Opt.TxtMotivoSospensione.Text = _campi.descrizione; } } //end for }
private void SaveDati(DataGrid Ctrl) { Hashtable _HS = null; if (Session["DatiListMP"] != null) { _HS = (Hashtable)Session["DatiListMP"]; } else { _HS = new Hashtable(); } foreach (DataGridItem o_Litem in Ctrl.Items) { System.Web.UI.WebControls.CheckBox cb = (System.Web.UI.WebControls.CheckBox)o_Litem.Cells[2].Controls[1]; System.Web.UI.WebControls.HyperLink link = (System.Web.UI.WebControls.HyperLink)o_Litem.Cells[3].Controls[0]; if (_HS.ContainsKey(link.Text)) { _HS.Remove(link.Text); } if (cb.Checked && cb.Enabled == true) { CPWRList _campi = new CPWRList(); /// WRList _campi = new WRList(); WebControls.UserOption Opt = (WebControls.UserOption)o_Litem.Cells[9].FindControl("UserOption1"); _campi.id = link.Text; _campi.stato = Opt.OptChiusaSospesa.Items[0].Selected; _campi.descrizione = Opt.TxtMotivoSospensione.Text; _HS.Add(_campi.id, _campi); } } //end for Session.Remove("DatiListMP"); Session.Add("DatiListMP", _HS); }