/// <summary>
        /// Generates the CodeBehind for the Editor
        /// </summary>
        /// <param name="pageName">The name of the page - can end with ASPX if you like but it will be stripped</param>
        /// <param name="providerName">The Data provider to use</param>
        /// <param name="tableName">Name of the table</param>
        /// <param name="languageType">Output language, i.e C# or that other one</param>
        /// <returns></returns>
        public static string GenerateCode(string pageName, string providerName, string tableName, LanguageType languageType)
        {
            //Grab the tableschema
            TableSchema.Table tbl          = DataService.GetTableSchema(tableName, providerName);
            string            pageTemplate = ResourceHelper.GetString(TemplateName.EDITOR_CODE);

            /*
             #NAMESPACE_USING# = if there is more than one provider, include this Using statement
             #PAGEBINDLIST# = The list that binds the page to the object
             #BINDLIST# = List that binds the object to the page
             #DROPLIST# = Loads each dropdown
             #CLASSNAME# = the name of the class
             */

            //make sure the providers are loaded
            DataService.LoadProviders();

            //Set the Namespace
            string namespaceUsing;

            //if (DataService.Databases.Count > 1)
            //{
            //have to use the namespace
            namespaceUsing = "using " + Utility.CheckNamingRules(tbl.Provider) + ";";
            //}
            pageTemplate = pageTemplate.Replace(TemplateVariable.NAMESPACE_USING, namespaceUsing);

            //Set the class name
            string className = tbl.ClassName;

            pageTemplate = pageTemplate.Replace(TemplateVariable.CLASS_NAME, className);

            //Set the page class name
            string pageClass = pageName.Replace(FileExtension.DOT_ASPX, String.Empty);

            pageTemplate = pageTemplate.Replace(TemplateVariable.PAGE_CLASS, pageClass);


            //now loop out the columns for each row of the table editor and grid
            StringBuilder bindRows     = new StringBuilder();
            StringBuilder pageBindRows = new StringBuilder();
            StringBuilder dropList     = new StringBuilder();

            foreach (TableSchema.TableColumn col in tbl.Columns)
            {
                string controlName = col.PropertyName;

                if (!col.IsPrimaryKey)
                {
                    if (col.IsForeignKey)
                    {
                        //dropdown lists

                        TableSchema.Table FKTable = DataService.GetForeignKeyTable(col, tbl);
                        if (FKTable != null)
                        {
                            dropList.AppendLine(AddTabs(2) + "Query qry" + controlName + " = " + FKTable.ClassName + ".CreateQuery();");
                            dropList.AppendLine(AddTabs(2) + "qry" + controlName + ".OrderBy = OrderBy.Asc(\"" + FKTable.Columns[1].ColumnName + "\");");
                            dropList.AppendLine(AddTabs(2) + "Utility.LoadDropDown(" + controlName + ", " + "qry" + controlName + ".ExecuteReader(), true);");
                            if (col.IsNullable)
                            {
                                dropList.AppendLine(AddTabs(2) + controlName + ".Items.Insert(0, new ListItem(\"(Not Specified)\", String.Empty));");
                            }
                        }
                    }
                    pageBindRows.AppendLine(SetControlValue(col, className));
                    if (col.DataType != DbType.Binary && col.DataType != DbType.Byte)
                    {
                        bindRows.AppendLine(GetControlValue(col, className));
                    }
                }
            }

            pageTemplate = pageTemplate.Replace(TemplateVariable.BIND_LIST, bindRows.ToString());
            pageTemplate = pageTemplate.Replace(TemplateVariable.PAGE_BIND_LIST, pageBindRows.ToString());
            pageTemplate = pageTemplate.Replace(TemplateVariable.DROP_LIST, dropList.ToString());


            return(pageTemplate);
        }