Ejemplo n.º 1
0
        /// <summary>
        /// Loads the data and data bind.
        /// </summary>
        private void LoadDataAndDataBind()
        {
            MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("MenuItemId", "MenuId", "IsRoot");

            DataTable dtSource = null;

            if (MenuItemId == 0)
            {
                IDataReader reader = mc.MenuItem.LoadAllRoot(SiteId);
                dtSource = ManagementHelper.ConvertToTable(reader);
                reader.Close();
            }
            else
            {
                DataTable menuTable = mc.MenuItem.LoadSubMenuDT(MenuItemId);
                foreach (DataRow row in menuTable.Rows)
                {
                    int itemId = (int)row["MenuItemId"];
                    using (IDataReader reader = mc.MenuItem.LoadById(itemId, LanguageId))
                    {
                        if (reader.Read())
                        {
                            row["Text"] = reader["Text"];
                        }
                        else
                        {
                            row["Text"] = "<span style='color:red;'>no localized version</span>";
                        }

                        reader.Close();
                    }
                }
                menuTable.Columns.Add(new DataColumn("IsDirectory", typeof(bool)));
                using (IDataReader par = mc.MenuItem.LoadParent(MenuItemId))
                {
                    if (par.Read())
                    {
                        DataRow newRow = menuTable.NewRow();
                        newRow["Text"]        = "[..]";
                        newRow["MenuItemId"]  = (int)par["MenuItemId"];
                        newRow["Order"]       = -1;
                        newRow["IsDirectory"] = true;
                        menuTable.Rows.InsertAt(newRow, 0);
                    }
                    par.Close();
                }

                dtSource = menuTable;
            }

            if (dtSource != null)
            {
                MyListView.DataSource = dtSource;
            }

            DataBind();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the data and data bind.
        /// </summary>
        /// <param name="sortExpression">The sort expression.</param>
        private void LoadDataAndDataBind(string sortExpression)
        {
            IDataReader reader = mc.WorkflowStatus.LoadByWorkflowId(WorkflowId);
            DataTable   table  = ManagementHelper.ConvertToTable(reader);

            reader.Close();

            MyListView.DataSource = table.DefaultView;
            if (table != null)
            {
                DataView view = table.DefaultView;
                view.Sort             = sortExpression;
                MyListView.DataSource = view;
            }

            MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("StatusId");
            MyListView.DataBind();
        }