Exemplo n.º 1
0
        protected void LoadArtistList()
        {
            ArtistController     sysmgr = new ArtistController();  //new instance
            List <SelectionList> info   = sysmgr.Artist_DDLList(); //fill new list by call to query from new instance

            //assume data collection needs to be sorted - could be done in BLL
            // X and Y => do the following
            info.Sort((x, y) => x.DisplayField.CompareTo(y.DisplayField)); //flip X and Y for opposite order

            //setup the DDL
            ArtistList.DataSource = info;                                   //attach data to object
            //ArtistList.DataTextField = "DisplayField";
            ArtistList.DataTextField  = nameof(SelectionList.DisplayField); //info holds objects and selectionlist holds deffinitions
            ArtistList.DataValueField = nameof(SelectionList.ValueField);
            ArtistList.DataBind();                                          //push into controller


            //prompt line
            ArtistList.Items.Insert(0, new ListItem("select...", "0")); //insert new item to DDL list
        }