public void MovieListView_UpdateItem([QueryString] int titleID) // Parameterns namn är samma som värdet DataKeyNames har. { //titelID = 66; if (ModelState.IsValid) { try { var movie = Service.GetMovie(titleID); if (movie == null) { ModelState.AddModelError(String.Empty, String.Format("Filmen med ID {0} hittades inte.", titleID)); return; } var checkBoxList = (CheckBoxList)MovieListView.FindControl("FormatCheckBoxList"); int[] format_ids = checkBoxList.Items.Cast <ListItem>().Where(li => li.Selected).Select(li => int.Parse(li.Value)).ToArray(); if (TryUpdateModel(movie)) { movie.TitelID = titleID; Service.SaveMovie(movie, format_ids); } Message = "Uppdateringen lyckades"; Response.Redirect("~/Pages/Home2.aspx", false); Context.ApplicationInstance.CompleteRequest(); } catch (Exception) { Message = "Uppdateringen misslyckades"; ModelState.AddModelError(String.Empty, "Ett oväntat fel inträffade då kunduppgiften skulle uppdateras."); } } }
protected void CheckCustomValidator_ServerValidate(object source, ServerValidateEventArgs args) { var checkBoxList = (CheckBoxList)MovieListView.FindControl("FormatCheckBoxList"); var checkBoxChecked = checkBoxList.SelectedItem; if (checkBoxChecked != null) { args.IsValid = true; } else { args.IsValid = false; } }
public TabbedHomePage() { ContentPage mPage = new ContentPage() { Title = "ALL" }; ContentView content = new MovieListView(0); content.ClassId = "0"; mPage.Content = content; mPage.ClassId = "0"; mPage.Title = "All"; Children.Add(mPage); var GList = App.MovieGenre.ToList(); foreach (var item in GList) { // Task.Run(()=>{ mPage = new ContentPage() { Title = item.Value }; content = new MovieListView(item.Key); content.ClassId = item.Key.ToString(); mPage.Content = content; mPage.ClassId = item.Key.ToString(); mPage.Title = item.Value.ToString(); Children.Add(mPage); //}); } InitializeComponent(); }