void GetGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.ToLower() == "add") { GridViewRow row = (e.CommandSource as Control).Parent.Parent as GridViewRow; Hashtable htd = new Hashtable(); foreach (TemplateField tf in GridViewManager1.GridView.Columns) { GenericItem item = tf.FooterTemplate as GenericItem; if (item == null) { continue; } try { foreach (DictionaryEntry de in item.ExtractValues(row)) { htd.Add(de.Key, de.Value); } } catch (Exception ex) { Exceptions.Logger.Error(ex); HtmlHelper.Alert(ex.Message, Page); return; } } try { AdminWorkFlowController ctrl = new AdminWorkFlowController(); AdminWorkFlowInfo info = new AdminWorkFlowInfo(); foreach (System.Reflection.PropertyInfo property in CBO.GetPropertyInfo(typeof(AdminWorkFlowInfo))) { if (htd[property.Name] != null) { property.SetValue(info, htd[property.Name], null); } } ctrl.InsertAdminWorkFlow(info); GridViewManager1.GridView.PageIndex = GridViewManager1.GridView.PageCount; GridViewManager1.LoadData(); } catch (Exception ex) { Exceptions.Logger.Error(ex); HtmlHelper.Alert(ex.Message, Page); } } }
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; }