protected void SearchAlbumsBTN_Click(object sender, EventArgs e) { if (ArtistList.SelectedIndex == 0) { //index 0 physiclaly points to the prompt line // "select an artist"; //using MessageUserControl for your own message.. MessageUserControl.ShowInfo("Search Concern", "select an artist"); ArtistAlbumList.DataSource = null; ArtistAlbumList.DataBind(); } else { //normally when leaving web page to class library you will want try-catch error handling //use MessageUserControll to handle errors // MessageUserControll has try-catch embedded inside its logic MessageUserControl.TryRun(() => { //bind to grid AlbumController sysmgr = new AlbumController(); //new instance //make a controller request to list object to use fot populating the Gridview List <ChinookSystem.ViewModels.ArtistAlbums> info = sysmgr.Albums_GetAlbumsForArtist(int.Parse(ArtistList.SelectedValue)); //fully qualify name to avoid descrepancies //bind list object to grid ArtistAlbumList.DataSource = info; ArtistAlbumList.DataBind(); }, "success message title", "success message goes here"); } }
protected void SearchAlbums_Click(object sender, EventArgs e) { if (ArtistList.SelectedIndex == 0) { //index 0 is physically pointing to prompt line // "Select an artist for the search"; //Using MessageUserControl for your own message //first version MessageUserControl.ShowInfo("Search Concern", "Select an artist"); //second version ArtistAlbumList.DataSource = null; ArtistAlbumList.DataBind(); } else { //user friendly error handling //normally when you leave web page to class library you want to have error handling //use MessageUserControl to handle errors which has try/catch EMBEDDED in its logic MessageUserControl.TryRun(() => { //standard lookup and assignment AlbumController sysmgr = new AlbumController(); List <ChinookSystem.ViewModels.ArtistAlbums> info = sysmgr.Albums_GetAlbumsForArtist(int.Parse(ArtistList.SelectedValue)); ArtistAlbumList.DataSource = info; ArtistAlbumList.DataBind(); }, "Success Message title", "Your success message here"); } }
protected void SearchAlbums_Click(object sender, EventArgs e) { if (ArtistList.SelectedIndex == 0) { //index 0 is physically pointing to the prompt line //Message.Text = "Select an artist for the search"; //using MessageUserControl for your own message MessageUserControl.ShowInfo("Search concern", "Select an artist for the search"); ArtistAlbumList.DataSource = null; ArtistAlbumList.DataBind(); } else { //user friendly error handling //normally when you leave the web page to your class library, you will want to have error handling (aka try/catch) //use MessageUserControl to handle errors //MessageUserControl has try/catch embedded inside its logic MessageUserControl.TryRun(() => { //standard lookup and assignment AlbumController sysmgr = new AlbumController(); List <ChinookSystem.ViewModels.ArtistAlbums> info = sysmgr.Albums_GetAlbumsForArtist(int.Parse(ArtistList.SelectedValue)); ArtistAlbumList.DataSource = info; ArtistAlbumList.DataBind(); }, "Success Message title", "your success message goes here"); } }
protected void SearchAlbums_Click(object sender, EventArgs e) { if (ArtistList.SelectedIndex == 0) { MessageLabel.Text = "Please select an artist!!!"; ArtistAlbumList.DataSource = null; ArtistAlbumList.DataBind(); } else { MessageLabel.Text = ""; //show the gridview AlbumController sysmgr = new AlbumController(); List <ChinookSystem.ViewModels.ArtistAlbums> info = sysmgr.Albums_GetAlbumsForArtist(int.Parse(ArtistList.SelectedValue)); ArtistAlbumList.DataSource = info; ArtistAlbumList.DataBind(); } }
protected void SearchAlbums_Click(object sender, EventArgs e) { if (ArtistList.SelectedIndex == 0) { MessageUserControl.ShowInfo("Must select an artist."); ArtistAlbum_Grid.DataSource = null; ArtistAlbum_Grid.DataBind(); } else { MessageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); List <ChinookSystem.ViewModels.ArtistAlbums> info = sysmgr.Albums_GetAlbumsForArtist(int.Parse(ArtistList.SelectedValue)); ArtistAlbum_Grid.DataSource = info; ArtistAlbum_Grid.DataBind(); }, "Success title", "Success message"); } }
protected void SearchAlbums_Click(object sender, EventArgs e) { if (ArtistList.SelectedIndex == 0) { //index 0 is physically pointing to the prompt line Message.Text = "Select an artist for the search."; ArtistAlbumList.DataSource = null; ArtistAlbumList.DataBind(); } else { //standard lookup and assignment AlbumController sysmgr = new AlbumController(); List <ChinookSystem.ViewModels.ArtistAlbums> info = sysmgr.Albums_GetAlbumsForArtist( int.Parse(ArtistList.SelectedValue)); ArtistAlbumList.DataSource = info; ArtistAlbumList.DataBind(); } }
protected void SearchAlbums_Click(object sender, EventArgs e) { if (ArtistList.SelectedIndex == 0) { //Am I on the first physical line (prompt line) of the DDL MessageUserControl.ShowInfo("Search Selection Concern", "Select an artist for the search."); ArtistAlbumList.DataSource = null; ArtistAlbumList.DataBind(); } else { MessageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); List <ChinookSystem.ViewModels.ArtistAlbums> info = sysmgr.Albums_GetAlbumsForArtist( int.Parse(ArtistList.SelectedValue)); ArtistAlbumList.DataSource = info; ArtistAlbumList.DataBind(); }, "Search Results", "The list of albums for the selected artist"); } }