protected void ListPhotos_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "EditCap") { String Caption = Convert.ToString(((Label)e.Item.FindControl("MMore")).Text); ((TextBox)e.Item.FindControl("Edit_Text")).Visible = true; ((TextBox)e.Item.FindControl("Edit_Text")).Text = Caption; ((Button)e.Item.FindControl("saveEditing2")).Visible = true; ((Button)e.Item.FindControl("Canccel")).Visible = true; } else if (e.CommandName == "savingCap") { int Id = Convert.ToInt32(((Button)e.Item.FindControl("Edit_Caption")).CommandArgument); String FullCaption = ((TextBox)e.Item.FindControl("Edit_Text")).Text; con.Open(); update_Caption(FullCaption, Id); con.Close(); ((TextBox)e.Item.FindControl("Edit_Text")).Visible = false; ((Button)e.Item.FindControl("saveEditing2")).Visible = false; ((Button)e.Item.FindControl("Canccel")).Visible = false; ListPhotos.DataBind(); } else if (e.CommandName == "deletingPhoto") { int Id = Convert.ToInt32(((Button)e.Item.FindControl("removephoto")).CommandArgument); con.Open(); delete_photo(Id); String img_Name = ((Image)e.Item.FindControl("Image1")).ImageUrl; File.Delete(Server.MapPath(img_Name)); con.Close(); Response.Redirect("ShowImagesGallery.aspx"); } else if (e.CommandName == "canccel") { ((TextBox)e.Item.FindControl("Edit_Text")).Visible = false; ((Button)e.Item.FindControl("saveEditing2")).Visible = false; ((Button)e.Item.FindControl("Canccel")).Visible = false; } else if (e.CommandName == "MMMore") { String FullText = ((Label)e.Item.FindControl("MMore")).Text; ((Label)e.Item.FindControl("Caption")).Text = FullText; ((LinkButton)e.Item.FindControl("Lesss")).Visible = true; ((LinkButton)e.Item.FindControl("Moree")).Visible = false; } else if (e.CommandName == "MMLess") { String partOfText = Convert.ToString(((Label)e.Item.FindControl("Caption")).Text); ((Label)e.Item.FindControl("Caption")).Text = partOfText.Substring(0, (partOfText.Length) / 2); ((LinkButton)e.Item.FindControl("Lesss")).Visible = false; ((LinkButton)e.Item.FindControl("Moree")).Visible = true; } }
void selectAll_Click(object sender, EventArgs e) { foreach (var item in ListPhotos.ItemsSource) { var container = ListPhotos.ContainerFromItem(item) as LongListMultiSelectorItem; if (container != null) { container.IsSelected = true; } } }
// GET: Photo/List?{PageNum} // If the page number is not included, set it to 0 public ActionResult List(int PageNum = 0) { ListPhotos ViewModel = new ListPhotos(); ViewModel.isadmin = User.IsInRole("admin"); // Grab all photos string url = "photodata/getphotos"; // Send off an HTTP request // GET : /api/photodata/getphotos // Retrieve response HttpResponseMessage response = client.GetAsync(url).Result; // If the response is a success, proceed if (response.IsSuccessStatusCode) { // Fetch the response content into IEnumerable<PlayerDto> IEnumerable <PhotoDto> SelectedPhotos = response.Content.ReadAsAsync <IEnumerable <PhotoDto> >().Result; // -- Start of Pagination Algorithm -- // Find the total number of photos int PhotoCount = SelectedPhotos.Count(); // Number of photos to display per page int PerPage = 8; // Determines the maximum number of pages (rounded up), assuming a page 0 start. int MaxPage = (int)Math.Ceiling((decimal)PhotoCount / PerPage) - 1; // Lower boundary for Max Page if (MaxPage < 0) { MaxPage = 0; } // Lower boundary for Page Number if (PageNum < 0) { PageNum = 0; } // Upper Bound for Page Number if (PageNum > MaxPage) { PageNum = MaxPage; } // The Record Index of our Page Start int StartIndex = PerPage * PageNum; //Helps us generate the HTML which shows "Page 1 of ..." on the list view ViewData["PageNum"] = PageNum; ViewData["PageSummary"] = " " + (PageNum + 1) + " of " + (MaxPage + 1) + " "; // -- End of Pagination Algorithm -- // Send back another request to get photos in page format url = "photodata/getphotospage/" + StartIndex + "/" + PerPage; response = client.GetAsync(url).Result; // Retrieve the response of the HTTP Request IEnumerable <PhotoDto> SelectedPhotosPage = response.Content.ReadAsAsync <IEnumerable <PhotoDto> >().Result; ViewModel.photos = SelectedPhotosPage; //Return the paginated of players instead of the entire list return(View(ViewModel)); } else { // If we reach here something went wrong with our list algorithm return(RedirectToAction("Error")); } }