protected void gvSubFolder_RowUpdate(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                int         index            = e.RowIndex;
                GridViewRow row              = gvFilters.Rows[index];
                Int64       Id               = Int64.Parse(gvFilters.DataKeys[index].Value.ToString());
                TextBox     txtSubFilterName = (TextBox)row.Cells[0].FindControl("txtSubFilterName");
                if (txtSubFilterName.Text.Trim() == "")
                {
                    Master.MessageCenter.DisplayWarningMessage(GlobalStrings.GetText(@"ErrorSubFilterName"));
                    return;
                }
                Query q = new Query(SubFilter.TableSchema).Where(SubFilter.Columns.SubFilterName, txtSubFilterName.Text.Trim())
                          .AddWhere(SubFilter.Columns.FilterId, WhereComparision.EqualsTo, FilterId)
                          .AddWhere(SubFilter.Columns.SubFilterId, WhereComparision.NotEqualsTo, Id);
                if (q.GetCount() > 0)
                {
                    Master.MessageCenter.DisplayErrorMessage(FiltersStrings.GetText(@"MessageSubFiltersAlreadyExists"));
                    return;
                }

                SubFilter subFilter = SubFilter.FetchByID(Id);
                subFilter.SubFilterName = txtSubFilterName.Text.Trim();
                subFilter.Save();
                gvFilters.EditIndex = -1;

                LoadItems();
            }
            catch (Exception) { }
        }
        protected void btnImport_Click(object sender, EventArgs e)
        {
            if (CsvDataTable != null)
            {
                int count = 0;
                try
                {
                    foreach (DataRow row in CsvDataTable.Rows)
                    {
                        if (row["Comments"].ToString() == "")
                        {
                            Filter f = Filter.FetchByName(row["FilterName"].ToString());
                            if (f == null)
                            {
                                f            = new Filter();
                                f.FilterName = row["FilterName"].ToString();
                                f.Save();
                            }
                            SubFilter sub = new SubFilter();
                            sub.SubFilterName = row["SubFilterName"].ToString();
                            sub.FilterId      = f.FilterId;
                            sub.Save();
                            count++;
                        }
                    }

                    lblImportResult.Text = ProductsStrings.GetText(@"MessageImportSuccess");
                }
                catch
                {
                    lblImportResult.Text = ProductsStrings.GetText(@"MessageImportFailedUnknown");
                }
                phImportResult.Visible = true;
                lblTotalImported.Text  = count.ToString();
                btnImport.Enabled      = false;
                phErrors.Visible       = false;
                phProductsList.Visible = false;
            }
        }
        protected void gvSubFolder_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (!e.CommandName.Equals("AddNew"))
                {
                    return;
                }

                GridViewRow row   = gvFilters.FooterRow;
                int         index = gvFilters.EditIndex;
                TextBox     txtSubFilterNameNew = (TextBox)row.Cells[0].FindControl("txtSubFilterNameNew");
                if (txtSubFilterNameNew.Text.Trim() == "")
                {
                    Master.MessageCenter.DisplayErrorMessage(GlobalStrings.GetText(@"ErrorSubFilterName"));
                    return;
                }
                Query q = new Query(SubFilter.TableSchema).Where(SubFilter.Columns.SubFilterName, txtSubFilterNameNew.Text.Trim())
                          .AddWhere(SubFilter.Columns.FilterId, WhereComparision.EqualsTo, FilterId);
                if (q.GetCount() > 0)
                {
                    Master.MessageCenter.DisplayErrorMessage(FiltersStrings.GetText(@"MessageSubFiltersAlreadyExists"));
                    return;
                }

                SubFilter subFilter = new SubFilter();
                subFilter.FilterId      = FilterId;
                subFilter.SubFilterName = txtSubFilterNameNew.Text.Trim();
                subFilter.Save();
                gvFilters.EditIndex = -1;

                // refresh the grid view data
                LoadItems();
            }
            catch (Exception) { }
        }