Пример #1
0
        private void BindAssetList()
        {
            // Get assets
            AssetFinder finder = new AssetFinder();

            finder.AssetIdList.Add(0);
            finder.AssetIdList.AddRange(UploadedAssetIdList);
            finder.AssetTypeId = AssetTypeDropDownList1.SelectedId;

            List <Asset> assetList = Asset.FindMany(finder);

            //Ensure that the items that have been added via the "template catalogue" are first in the list.
            List <Asset> tempAssetList = new List <Asset>();

            foreach (int Id in SessionInfo.Current.User.GetCatalogueAssetIdList())
            {
                var asset = assetList.Where(a => a.AssetId == Id).SingleOrDefault();

                if (asset != null)
                {
                    assetList.Remove(asset);
                    tempAssetList.Add(asset);
                }
            }

            // Parse into a new list
            var list = from a in tempAssetList
                       select new { a.AssetId, Text = a.AssetId + " (" + a.Filename + ")" };

            // Bind the listbox
            SessionAssetsListBox.DataSource     = list;
            SessionAssetsListBox.DataTextField  = "Text";
            SessionAssetsListBox.DataValueField = "AssetId";
            SessionAssetsListBox.DataBind();

            SelectFirstAsset();
        }