Esempio n. 1
0
        /*
         * Init checkbox fields to exclude the key column
         */
        void InitCheckboxFields()
        {
            CheckBoxListInputColumns.DataSource = null;
            CheckBoxListInputColumns.DataBind();

            CheckBoxListPredictColumns.DataSource = null;
            CheckBoxListPredictColumns.DataBind();

            // execute query
            SQLManager manager  = new SQLManager(sCatalog);
            DataTable  objTable = new DataTable();

            // handle errors
            //if (manager.GetQueryResult(sQueryText) == null)
            //{
            //    HandleQueryError();
            //    return;
            //}

            // exclude the key column
            string sQueryTextExclude = "SELECT COLUMN_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" +
                                       DropDownListTables.SelectedItem.ToString() + "' AND COLUMN_NAME <> '" + DropDownListKey.SelectedItem.ToString() + " 'ORDER BY ORDINAL_POSITION";

            objTable.Load(manager.GetQueryResult(sQueryTextExclude));

            CheckBoxListInputColumns.DataSource     = objTable;
            CheckBoxListInputColumns.DataTextField  = "COLUMN_NAME";
            CheckBoxListInputColumns.DataValueField = "ORDINAL_POSITION";
            CheckBoxListInputColumns.DataBind();

            CheckBoxListPredictColumns.DataSource     = objTable;
            CheckBoxListPredictColumns.DataTextField  = "COLUMN_NAME";
            CheckBoxListPredictColumns.DataValueField = "ORDINAL_POSITION";
            CheckBoxListPredictColumns.DataBind();

            manager.CloseConnection();
        }
Esempio n. 2
0
        /*
         * Initialize column names in checkbox list and dropdown box
         */
        void InitializeColumns(DataTable objMainTable)
        {
            if (objMainTable == null)
            {
                return;
            }

            // reset controlls
            DropDownListKey.DataSource = null;
            DropDownListKey.DataBind();

            CheckBoxListInputColumns.DataSource = null;
            CheckBoxListInputColumns.DataBind();

            // add columns
            for (int i = 0; i < objMainTable.Columns.Count; i++)
            {
                DropDownListKey.Items.Add(objMainTable.Columns[i].ColumnName.ToString());
                CheckBoxListInputColumns.Items.Add(objMainTable.Columns[i].ColumnName.ToString());
            }

            DropDownListKey.DataBind();
            CheckBoxListInputColumns.DataBind();
        }