private void IniteStatelist() { var context = new CLDMSEntities(); var dtDealerCityAccount = context.SelectedCities.Where(x => x.AccountId == GlobalVar.CurrentAccount.AccountId).ToList(); IQueryable <IGrouping <string, City> > statelist = context.Cities.OrderBy(j => j.State).GroupBy(i => i.State); foreach (var state in statelist) { var treeNode = new TreeNode(state.Key, state.OrderBy(i => i.CityName) .Select( city => new TreeNode(city.CityName) { Tag = city.CityID, Checked = dtDealerCityAccount.FirstOrDefault( i => i.CityId == city.CityID) != null }) .ToArray()); StateTreeview.Nodes.Add(treeNode); GridviewHelper.HideCheckBox(StateTreeview, treeNode); } }
protected void FilterCommand(GridViewCommandEventArgs e) { GridViewRow row = (e.CommandSource as Control).Parent.Parent as GridViewRow; string filterExpression = string.Empty; foreach (TemplateField tf in gvManager.Columns) { GenericItem item = tf.HeaderTemplate as GenericItem; if (item == null) { continue; } foreach (DictionaryEntry de in item.ExtractValues(row)) { string key = "[" + de.Key + "]"; string value; if (de.Value == DBNull.Value) { value = " IS NULL"; } else if (de.Value.GetType() == typeof(string)) { value = " LIKE '%" + de.Value.ToString() + "%' "; } else if (de.Value.GetType() == typeof(DateTime)) { value = "='" + de.Value.ToString() + "'"; } else { value = "=" + de.Value.ToString(); } filterExpression += " AND " + key + value; } } filterExpression = GridviewHelper.getFilter(filterExpression); ViewState[this.ClientID + "FilterExpression"] = filterExpression; }