private async Task loadBooks(serviceDAO service, int init, int currentPage) { List<BookFull> books; if (ddlAuthorsActives.SelectedValue=="0") books = await service.GetAllBooksFull(0); else books = await service.GetAllBooksFull(Int32.Parse(ddlAuthorsActives.SelectedValue)); int fin = init + gvBooks.PageSize; if (books != null && fin > books.Count) fin = books.Count; gvBooks.PageIndex = currentPage; gvBooks.DataSource = books; gvBooks.DataBind(); for (int i = init; i < fin; i++) { ((ImageButton)gvBooks.Rows[i].Cells[6].Controls[0]).ImageUrl = "images/flags/" + books[i].Country + ".png"; ((ImageButton)gvBooks.Rows[i].Cells[7].Controls[0]).Attributes.Add("OnClick", "if(!confirm('The entry will be deleted, are you sure?'))return false;"); } }
private async Task loadAuthorsActives(serviceDAO service) { List<BookFull> books = await service.GetAllBooksFull(0); foreach (BookFull bf in books) { ListItem item = new ListItem(); item.Text = bf.Author; item.Value = bf.IdAuthor.ToString(); if(ddlAuthorsActives.Items.FindByValue(item.Value)==null) ddlAuthorsActives.Items.Add(item); } ListItem selec = new ListItem("All", "0"); ddlAuthorsActives.DataBind(); selec.Selected = true; ddlAuthorsActives.Items.Insert(0, selec); }
protected async void ddlAuthorsActives_SelectedIndexChanged(object sender, EventArgs e) { serviceDAO service = new serviceDAO(); List<BookFull> books; if (ddlAuthorsActives.SelectedValue == "0") books = await service.GetAllBooksFull(0); else books = await service.GetAllBooksFull(Int32.Parse(ddlAuthorsActives.SelectedValue)); gvBooks.DataSource = books; gvBooks.DataBind(); for (int i = 0; i < gvBooks.Rows.Count; i++) { ((ImageButton)gvBooks.Rows[i].Cells[6].Controls[0]).ImageUrl = "images/flags/" + books[i].Country + ".png"; ((ImageButton)gvBooks.Rows[i].Cells[7].Controls[0]).Attributes.Add("OnClick", "if(!confirm('The entry will be deleted, are you sure?'))return false;"); } }