protected void Page_Load(object sender, EventArgs e)
        {
            ColsSearch = new SelectedColumns.Search(myCook.GetCookieSQL("SearchResultsSearch"));
            ColsExcel  = new SelectedColumns.Excel(myCook.GetCookieSQL("SearchResultsExcel"));

            if (Request["__EVENTTARGET"] == "Return")
            {
                Response.Redirect(getPageName());
            }

            if (Request["__EVENTTARGET"] == "LoadDefaults")
            {
                myCook.SetCookieSQL("SearchResultsSearch", "");
                myCook.SetCookieSQL("SearchResultsExcel", "");
                Response.Redirect("SearchResultsSettings.aspx?" + Request.QueryString);
            }

            setColumnSelectFields();
            ConfigurePage();
        }
        private void SetupGridView(bool useExcel)
        {
            ITemplate  template;
            BoundField bf;

            GV.Columns.Clear();

            if (myActiveList)
            {
                GV.Columns.Add(buildBoundField("Response Required", "responserequired", 0, true, ""));
            }

            List <SelectedColumns.Column> lstSelColumns = null;

            if (useExcel)
            {
                SelectedColumns.Excel ColsSearch = new SelectedColumns.Excel(myCook.GetCookieSQL("SearchResultsExcel"));
                lstSelColumns = ColsSearch.getSelectedColumns();
            }
            else
            {
                SelectedColumns.Search ColsSearch = new SelectedColumns.Search(myCook.GetCookieSQL("SearchResultsSearch"));
                lstSelColumns = ColsSearch.getSelectedColumns();
            }

            foreach (SelectedColumns.Column c in lstSelColumns)
            {
                switch (c.dbFieldName)
                {
                case "friendlyName":
                    string args     = "";
                    string location = "";
                    template = new GridViewTemplate_LinkButton_WF(location, _webServer + _appPath, args);
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "DateCreated":
                case "StartedDateTime":
                case "StepStartTime":
                    template = new GridViewTemplate_LabelDate(c.HeaderText, c.dbFieldName, _culture);
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "CreatedBy":
                case "StartedBy":
                    template = new GridViewTemplate_LabelUser(c.HeaderText, c.dbFieldName, AU);
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "Status":
                    template = new GridViewTemplate_Status(tools, workflow2);
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "onTime":
                    template = new GridViewTemplate_Boolean(c.dbFieldName, GridViewTemplate_Boolean.DisplayValue.yesNo, true, false);
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "AssignedTo":
                    if (joinUsers)
                    {
                        template = new GridViewTemplate_HTML("AssignedToFriendlyName");
                        GV.Columns.Add(makeLabelTemplate(false, c, template));
                    }
                    break;

                case "Type":
                    template = new GridViewTemplate_HTML("Type_Friendly");
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "Condition":
                    template = new GridViewTemplate_HTML("Condition_Friendly");
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "Response":
                    template = new GridViewTemplate_HTML("Response_Friendly");
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "Comment":
                case "StepDescription":
                case "stepUsers":
                case "DaysInQueue":
                    template = new GridViewTemplate_HTML(c.dbFieldName);
                    c.wrap   = true;
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                case "Comments":
                    if (joinUsers)
                    {
                        template = new GridViewTemplate_HTML(c.dbFieldName);
                        c.wrap   = true;
                        GV.Columns.Add(makeLabelTemplate(false, c, template));
                    }
                    break;

                case "Department":
                case "Equipment":
                case "Originator":
                    template = new GridViewTemplate_HTML(c.dbFieldName);
                    GV.Columns.Add(makeLabelTemplate(false, c, template));
                    break;

                default:
                    bf = buildBoundField(c, 0);
                    if (c.HeaderText == "Comment")
                    {
                        bf.ItemStyle.Wrap = true;
                    }
                    GV.Columns.Add(bf);
                    break;
                }
            }
        }