示例#1
0
        protected void BindArtistList()
        {
            ArtistController sysmgr = new ArtistController();
            List <Artist>    info   = sysmgr.ArtistList();

            info.Sort((x, y) => x.Name.CompareTo(y.Name)); //Ascending
            //For Descending, it will be:
            //info.Sort((x, y) => y.Name.CompareTo(x.Name));
            ArtistList.DataSource     = info;
            ArtistList.DataTextField  = nameof(Artist.Name);
            ArtistList.DataValueField = nameof(Artist.ArtistId); //Previously we used to do "ArtistId" but this will make sure the spelling here is correct]
            ArtistList.DataBind();
            //ArtistList.Items.Insert(0, "Select ...");
        }