protected void LoadArtistList()
        {
            //  user friendly error handling (aka try/catch)

            //use the usercontrol MessageUserControl to manage the
            //    error handling for the web page when control
            //    leaves the web page and goes to the class library

            MessageUserControl.TryRun(() => {
                //what goes inside the coding block?
                //your code that would normally be inside the try portion of a try/catch
                ArtistController sysmgr   = new ArtistController();
                List <SelectionList> info = sysmgr.Artists_DDLList();

                //let's assume the data collection needs to be sorted
                info.Sort((x, y) => x.DisplayField.CompareTo(y.DisplayField));

                //setup the ddl
                ArtistList.DataSource = info;
                //ArtistList.DataTextField = "DisplayField";
                ArtistList.DataTextField  = nameof(SelectionList.DisplayField);
                ArtistList.DataValueField = nameof(SelectionList.ValueField);
                ArtistList.DataBind();

                //setup of a prompt line
                ArtistList.Items.Insert(0, new ListItem("select ...", "0"));
            }, "Success title message", "the succes title and body message are optional");
        }
        protected void LoadArtistList()
        {
            ArtistController     sysmgr = new ArtistController();
            List <SelectionList> info   = sysmgr.Artists_DDLList();

            //Lets assume the data collection needs to be sorted
            info.Sort((x, y) => x.DisplayField.CompareTo(y.DisplayField));

            //set up the DDL
            ArtistList.DataSource = info;
            //ArtistList.DataTextField = "DisplayField";
            ArtistList.DataTextField  = nameof(SelectionList.DisplayField);
            ArtistList.DataValueField = nameof(SelectionList.ValueField);
            ArtistList.DataBind();

            ArtistList.Items.Insert(0, new ListItem("Select ...", "0"));
        }
Пример #3
0
        protected void LoadArtistList()
        {
            ArtistController     sysmgr = new ArtistController();
            List <SelectionList> info   = sysmgr.Artists_DDLList();

            // lets assume the data collection needs to be sort
            info.Sort((x, y) => x.DisplayField.CompareTo(y.DisplayField));

            //setup the ddl
            ArtistList.DataSource = info;                                   //ArtistList is the DropDownList ID
            //ArtistList.DataTextField = "DisplayField";
            ArtistList.DataTextField  = nameof(SelectionList.DisplayField); //nameof(object.prop)
            ArtistList.DataValueField = nameof(SelectionList.ValueField);   //nameof(object.prop)
            ArtistList.DataBind();                                          // use to show the data in ddl. without it, data does not get in ddl

            //prompt line
            ArtistList.Items.Insert(0, new ListItem("select...", "0"));
        }
Пример #4
0
        protected void LoadArtistList()
        {
            ArtistController     sysmgr = new ArtistController();
            List <SelectionList> info   = sysmgr.Artists_DDLList();

            //lets assume data collection needs to be sorted (ascending order)
            // for x and y, do the following...
            //lambda (=>) will supply the delegate (on the right side of =>)
            //compare x display field to y display field
            info.Sort((x, y) => x.DisplayField.CompareTo(y.DisplayField));

            //setup the ddl
            ArtistList.DataSource     = info;
            ArtistList.DataTextField  = nameof(SelectionList.DisplayField);
            ArtistList.DataValueField = nameof(SelectionList.ValueField);
            ArtistList.DataBind();

            //setup of a prompt line, at position 0...
            ArtistList.Items.Insert(0, new ListItem("Please select...", "0"));
        }
Пример #5
0
        protected void LoadArtistList()
        {
            ArtistController     sysmgr = new ArtistController();
            List <SelectionList> info   = sysmgr.Artists_DDLList();

            //let's assume the data collection needs to be sorted
            info.Sort((x, y) => x.DisplayField.CompareTo(y.DisplayField));

            //setup the ddl
            ArtistList.DataSource = info;

            //OLD WAY
            //ArtistList.DataTextField = "Displayfield";

            //NEW WAY
            ArtistList.DataTextField  = nameof(SelectionList.DisplayField);
            ArtistList.DataValueField = nameof(SelectionList.ValueField);
            ArtistList.DataBind();

            //prompt line -- a more "complete and proper" way of inserting a prompt
            ArtistList.Items.Insert(0, new ListItem("Select...", "0"));
        }