protected void BtnFilter_Click(object sender, EventArgs e) { PnlSearch.BindControls(FilterDictionary, _TableName, true); Cache.Remove(_TableName._ToString()); Config.RedirectURL("/tools/applicationspersons/?p=1"); }
protected void BtnFilter_Click(object sender, EventArgs e) { PnlSearch.BindControls(FilterDictionary, TableName, true); Cache.Remove(TableName._ToString()); Config.RedirectURL("/tools/electronicregistry/?p=1"); }
public static void BindControls(this Control Panel, Dictionary <string, object> FilterDictionary, Tools.Table TableName, bool ClearSession = false) { string SessionName = TableName._ToString(); if (ClearSession) { HttpContext.Current.Session[SessionName] = null; } if (HttpContext.Current.Session[SessionName] != null) { if (FilterDictionary.Count < 1) { FilterDictionary = (Dictionary <string, object>)HttpContext.Current.Session[SessionName]; } foreach (Control item in Panel.Controls) { if (item.HasControls()) { BindControls(item, FilterDictionary, TableName); } try { if (item is TextBox) { TextBox Txt = item as TextBox; Txt.Text = FilterDictionary[Txt.ID]._ToString(); } else if (item is DropDownList) { DropDownList DList = item as DropDownList; DList.SelectedValue = FilterDictionary[DList.ID]._ToString(); } else if (item is ListBox) { ListBox LstBx = item as ListBox; for (int i = 0; i < LstBx.Items.Count; i++) { ListItem Item = LstBx.Items[i]; if (FilterDictionary[LstBx.ID]._ToString().IndexOf(Item.Value) > -1) { Item.Selected = true; } } } else if (item is CheckBox) { CheckBox Check = item as CheckBox; Check.Checked = (bool)FilterDictionary[Check.ID]; } } catch { HttpContext.Current.Session[SessionName] = null; FilterDictionary.Clear(); BindControls(Panel, FilterDictionary, TableName); } } } else { foreach (Control item in Panel.Controls) { if (item.HasControls()) { BindControls(item, FilterDictionary, TableName, true); } if (item is TextBox) { TextBox Txt = item as TextBox; FilterDictionary.Add(Txt.ID, Txt.Text); } else if (item is DropDownList) { DropDownList DList = item as DropDownList; FilterDictionary.Add(DList.ID, DList.SelectedValue); } else if (item is ListBox) { ListBox LstBx = item as ListBox; StringBuilder Values = new StringBuilder(); for (int i = 0; i < LstBx.Items.Count; i++) { ListItem Item = LstBx.Items[i]; if (Item.Selected) { Values.Append(Item.Value + ","); } } FilterDictionary.Add(LstBx.ID, Values._ToString().Trim(',')); } else if (item is CheckBox) { CheckBox Check = item as CheckBox; FilterDictionary.Add(Check.ID, Check.Checked); } } HttpContext.Current.Session[SessionName] = FilterDictionary; } }