public SearchManager(List parent)
 {
     _parent = parent;
     _cmdSearch = parent.cmdSearch;
     _cmdSearch.Click += cmdSearch_Click;
     _cmdResetSearch = parent.cmdResetSearch;
     _cmdResetSearch.Click += cmdResetSearch_Click;
     _searchPlaceHolder = parent.phSearchSentence;
 }
        void BuildEditForm()
        {
            var fieldSettingsTable = FieldSettingsController.GetFieldSettingsTable(ModuleId);
            var editForm = new List<FormColumnInfo>();
            FormColumnInfo currentField;
            var security = new ModuleSecurity(ModuleContext);

            _editControls = new EditControls(ModuleContext);

            foreach (DataRow dr in Data.Tables[DataSetTableName.Fields].Rows)
            {
                var fieldTitle = dr[FieldsTableColumn.Title].AsString();
                var dataTypeName = dr[FieldsTableColumn.Type].AsString();
                var dataType = DataType.ByName(dataTypeName);

                var isColumnEditable =
                    Convert.ToBoolean((! dataType.SupportsHideOnEdit ||
                                       Convert.ToBoolean(dr[FieldsTableColumn.ShowOnEdit])) &&
                                      (! Convert.ToBoolean(dr[FieldsTableColumn.IsPrivate]) ||
                                       security.IsAllowedToEditAllColumns()));

                //If Column is hidden, the Fieldtype falls back to "String" as the related EditControl works perfect even if it is not visibile
                //EditControls of other user defined datatypes may use core controls (e.g. UrlControl or RTE) which are not rock solid regarding viewstate.
                if (! isColumnEditable && dataType.IsUserDefinedField)
                {
                    dataTypeName = "String";
                }

                currentField = new FormColumnInfo {IsUserDefinedField = dataType.IsUserDefinedField};

                if (dataType.IsSeparator)
                {
                    var fieldId = (int)dr[FieldsTableColumn.Id];
                    currentField.IsCollapsible = Data.Tables[DataSetTableName.FieldSettings].GetFieldSetting("IsCollapsible", fieldId).AsBoolean();
                    currentField.IsSeparator = true;
                    if (dr[FieldsTableColumn.Visible].AsBoolean())
                    {
                        currentField.Title = fieldTitle;
                    }
                    currentField.Visible = isColumnEditable;
                }
                else
                {
                    currentField.Help = dr[FieldsTableColumn.HelpText].AsString();
                    currentField.Title = dr[FieldsTableColumn.Title].AsString();
                    currentField.Required =
                        Convert.ToBoolean(dr[FieldsTableColumn.Required].AsBoolean() &&
                                          dataType.IsUserDefinedField);

                    //advanced Settings: Dynamic control
                    currentField.EditControl = _editControls.Add(dr[FieldsTableColumn.Title].AsString(),
                                                                dataTypeName, Convert.ToInt32(dr[FieldsTableColumn.Id]),
                                                                dr[FieldsTableColumn.HelpText].AsString(),
                                                                dr[FieldsTableColumn.Default].AsString(),
                                                                dr[FieldsTableColumn.Required].AsBoolean(),
                                                                dr[FieldsTableColumn.ValidationRule].AsString(),
                                                                dr[FieldsTableColumn.ValidationMessage].AsString(),
                                                                dr[FieldsTableColumn.EditStyle].AsString(),
                                                                dr[FieldsTableColumn.InputSettings].AsString(),
                                                                dr[FieldsTableColumn.OutputSettings].AsString(),
                                                                dr[FieldsTableColumn.NormalizeFlag].AsBoolean(),
                                                                dr[FieldsTableColumn.MultipleValues].AsBoolean(),
                                                                fieldSettingsTable,
                                                                this );
                    currentField.Visible = isColumnEditable;
                }
                editForm.Add(currentField);
            }

            if (CaptchaNeeded())
            {
                _ctlCaptcha = new CaptchaControl
                                  {
                                      ID = "Captcha",
                                      CaptchaWidth = Unit.Pixel(130),
                                      CaptchaHeight = Unit.Pixel(40),
                                      ToolTip = Localization.GetString("CaptchaToolTip", LocalResourceFile),
                                      ErrorMessage = Localization.GetString("CaptchaError", LocalResourceFile)
                                  };
                currentField = new FormColumnInfo
                                   {
                                       Title = Localization.GetString("Captcha", LocalResourceFile),
                                       EditControl = _ctlCaptcha,
                                       Visible = true,
                                       IsUserDefinedField = false
                                   };
                editForm.Add(currentField);
            }
            BuildCssForm(editForm);
            //Change captions of buttons in Form mode
            if (IsNewRow && Settings.ListOrForm.Contains("Form"))
            {
                cmdUpdate.Attributes["resourcekey"] = "cmdSend.Text";
     }
        }
 void cmdSearch_Click(object sender, EventArgs e)
 {
     if (! _parent.RenderMethod.StartsWith("UDT_Xsl"))
     {
         _parent.CurrentPage = 1;
         IsSearching = true;
     }
     else
     {
         var @params = new List<string>();
         var moduleId = _parent.ModuleId;
         if (! string.IsNullOrEmpty(TxtSearch.Text))
         {
             @params.Add(string.Format("u{0}q={1}", moduleId, TxtSearch.Text.UrlHexEncode()));
             if (! _parent.Settings.SimpleSearch )
             {
                 @params.Add(string.Format("u{0}c={1}", moduleId,
                                           DrpSearchableColumns.SelectedValue.UrlHexEncode()));
                 @params.Add(string.Format("u{0}m={1}", moduleId, DrpSearchMode.SelectedValue));
             }
             var url = Globals.NavigateURL(_parent.TabId, "", @params.ToArray());
             _parent.Response.Redirect(url);
         }
         // Such paramter
     }
 }
         void WriteData(DataTable data, DataTable fields, string folder, string fileName, string delimiter)
        {

            using (var sw = new StringWriter())
            {
                var columns = new List<string>();
                //Writing top line with column names
                foreach (DataRow row in fields.Rows)
                {
                    var typeName = (row[FieldsTableColumn.Type].ToString());
                    //ignore system fields
                    if (DataType.ByName(typeName).IsUserDefinedField)
                    {
                        columns.Add(row[FieldsTableColumn.Title].ToString());
                    }
                }

                //write colums name as first line
                CSVWriter.WriteCSV(columns.ToArray(), sw, delimiter);

                //writing data
                foreach (DataRow row in data.Rows)
                {
                    var values = new List<string>();
                    //getting values for all colums
                    foreach (var fieldTitle in columns)
                    {
                        var valueName = ((data.Columns.Contains(fieldTitle + DataTableColumn.Appendix_Original))
                                             ? fieldTitle + DataTableColumn.Appendix_Original
                                             : fieldTitle);
                        var value = row[valueName].AsString();
                        values.Add(value);
                    }
                    CSVWriter.WriteCSV(values.ToArray(), sw, delimiter);

                }
                WriteFile(folder, fileName, sw);
            }
        }