/// <summary>
    /// Load Columns names with Query.
    /// </summary>
    protected void LoadFromQuery()
    {
        string queryName = hdnClassNames.Value;

        var q = new DataQuery(queryName).TopN(1);

        if (!q.HasResults())
        {
            return;
        }

        DataView dv = q.Result.Tables[0].DefaultView;

        string[,] listItems = new string[dv.Table.Columns.Count, 2];

        int i = 0;

        foreach (DataColumn dc in dv.Table.Columns)
        {
            listItems[i, 0] = i.ToString();
            listItems[i, 1] = dc.ColumnName;
            i++;
        }

        ItemSelection1.LeftItems = listItems;
        ItemSelection1.fill();
    }
    /// <summary>
    /// Load Columns names into listbox.
    /// </summary>
    protected void LoadFromDataClass()
    {
        // Get selected classes from hiddenfield.
        ArrayList classesList = new ArrayList();
        ArrayList columnList  = new ArrayList();

        if (!string.IsNullOrEmpty(hdnClassNames.Value))
        {
            classesList = new ArrayList(hdnClassNames.Value.Split(';'));
        }

        classesList.Add("CMS.Tree");
        classesList.Add("CMS.Document");

        // Fill columnList with column names from all classes.
        foreach (string className in classesList)
        {
            try
            {
                if (!String.IsNullOrEmpty(className))
                {
                    IDataClass    dc  = DataClassFactory.NewDataClass(className);
                    DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(className);
                    // Get columns only from couplet classes.
                    if (dci.ClassIsCoupledClass)
                    {
                        foreach (string columnName in dc.StructureInfo.ColumnNames)
                        {
                            columnList.Add(columnName);
                        }
                    }
                }
            }
            catch
            {
            }
        }

        // Move columns from array list to string array and add indexes.
        string[,] columns = new string[columnList.Count, 2];
        int index = 0;

        foreach (string columnName in columnList)
        {
            columns[index, 0] = index.ToString();
            columns[index, 1] = columnName;
            index            += 1;
        }

        ItemSelection1.LeftItems = columns;
        ItemSelection1.fill();
    }
    /// <summary>
    /// Load Columns names with Query.
    /// </summary>
    protected void LoadFromQuery()
    {
        DataView dv = SqlHelperClass.ExecuteQuery(hdnClassNames.Value, null, null, null).Tables[0].DefaultView;

        string[,] mLI = new string[dv.Table.Columns.Count, 2];

        int i = 0;

        foreach (DataColumn dc in dv.Table.Columns)
        {
            mLI[i, 0] = i.ToString();
            mLI[i, 1] = dc.ColumnName;
            i++;
        }

        ItemSelection1.LeftItems = mLI;
        ItemSelection1.fill();
    }