protected void AlbumList_SelectedIndexChanged(object sender, EventArgs e) { //Standard lookup GridViewRow agvrow = AlbumList.Rows[AlbumList.SelectedIndex]; //Need to retrieve the value from a Web Control located within the gridview cell string albumid = (agvrow.FindControl("AlbumId") as Label).Text; //Time being, error handling will need to be added MessageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); Album datainfo = sysmgr.Album_Get(int.Parse(albumid)); if (datainfo == null) { //clear the controls //ClearControls(); //throw an exception throw new Exception("Record no longer exists on file"); } else { EditAlbumID.Text = datainfo.AlbumId.ToString(); EditTitle.Text = datainfo.Title; EditAlbumArtistList.SelectedValue = datainfo.ArtistId.ToString(); EditReleaseYear.Text = datainfo.ReleaseYear.ToString(); EditReleaseLabel.Text = datainfo.ReleaseLabel == null ? "" : datainfo.ReleaseLabel; } }, "Find Album", "Album Found" ); //Title and success message }
protected void AlbumList_SelectedIndexChanged(object sender, EventArgs e) { //access data located on the gridviewrow //template web control access syntax GridViewRow agvrow = AlbumList.Rows[AlbumList.SelectedIndex]; string albumid = (agvrow.FindControl("AlbumID") as Label).Text; // albumid = "0"; //testing to cause error - REMOVE AFTER TESTING MessageUserControl.TryRun(() => { //standard lookup AlbumController sysmgr = new AlbumController(); Album datainfo = sysmgr.Album_Get(int.Parse(albumid)); if (datainfo == null) { ClearControls(); throw new Exception("No Record Found for Selected Album"); } else { EditAlbumID.Text = datainfo.AlbumId.ToString(); EditTitle.Text = datainfo.Title; EditAlbumArtistList.SelectedValue = datainfo.ArtistId.ToString(); EditReleaseYear.Text = datainfo.ReleaseYear.ToString(); EditReleaseLabel.Text = datainfo.ReleaseLabel == null ? "" : datainfo.ReleaseLabel; } }, "Album Serach", "View Album Details"); }
protected void AlbumList_SelectedIndexChanged(object sender, EventArgs e) { //standard lookup //Making an alias ↓ GridViewRow agvrow = AlbumList.Rows[AlbumList.SelectedIndex]; //retrieve the value from a web control located within the Gridview cell //Whenver a new item is selected in grid, this will return the selected index. From that we can extract a single selected list object string albumId = (agvrow.FindControl("AlbumId") as Label).Text; //error handling will need to be added MessageUserControl.TryRun(() => { //place your processing code AlbumController sysmgr = new AlbumController(); Album datainfo = sysmgr.Album_Get(int.Parse(albumId)); if (datainfo == null) { //ClearControls(); //throw an exception throw new Exception("Record no longer exists on file."); } else { EditAlbumID.Text = datainfo.AlbumId.ToString(); EditTitle.Text = datainfo.Title; EditAlbumArtistList.SelectedValue = datainfo.ArtistId.ToString(); EditReleaseYear.Text = datainfo.ReleaseYear.ToString(); EditReleaseLabel.Text = datainfo.ReleaseLabel == null ? "" : datainfo.ReleaseLabel; } }, "Find Album" /*Title*/, "AlbumFound" /*Success Message*/); //Strings on this line are success message }
protected void AlbumList_SelectedIndexChanged(object sender, EventArgs e) { //standard lookup GridViewRow agvrow = AlbumList.Rows[AlbumList.SelectedIndex]; //retreive the value from a web control located within // the GridView cell string albumid = (agvrow.FindControl("AlbumId") as Label).Text; //error handling will need to be added MessageUserControl.TryRun(() => { //place your processing code AlbumController sysmgr = new AlbumController(); Album datainfo = sysmgr.Album_Get(int.Parse(albumid)); if (datainfo == null) { ClearControls(); throw new Exception("Record no longer exists on file."); } else { EditAlbumID.Text = datainfo.AlbumId.ToString(); EditTitle.Text = datainfo.Title; EditAlbumArtistList.SelectedValue = datainfo.ArtistId.ToString(); EditReleaseYear.Text = datainfo.ReleaseYear.ToString(); EditReleaseLabel.Text = datainfo.ReleaseLabel == null ? "" : datainfo.ReleaseLabel; } }, "Find Album", "Album found"); //strings on this line are success message }
protected void AlbumList_SelectedIndexChanged(object sender, EventArgs e) { //standard lookup/query //get data from the gridview line that was selected GridViewRow agvrow = //pointer to the gridview row that we want to look at AlbumList.Rows[AlbumList.SelectedIndex]; //retreive the value from a web control located within //the GridView cell //gets contents within a cell on a webcontrol with type specification ending in //the proper access technique. string albumid = (agvrow.FindControl("AlbumId") as Label).Text; messageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); Album datainfo = sysmgr.Album_Get(int.Parse(albumid)); if (datainfo == null) { ClearControls(); //throw an exception at dem bitchez throw new Exception("Record no longer exists on file."); } else { EditAlbumID.Text = datainfo.AlbumId.ToString(); EditTitle.Text = datainfo.Title; EditAlbumArtistList.SelectedValue = datainfo.ArtistId.ToString(); EditReleaseYear.Text = datainfo.ReleaseYear.ToString(); EditReleaseLabel.Text = datainfo.ReleaseLabel == null ? "" : datainfo.ReleaseLabel; } }, "Find Album", "Album found"); //Title and success message //error handling will need to be added (later). //The standard lookup is connecting to the controller }