protected void GridViewAuthors_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridViewAuthors.PageIndex = e.NewPageIndex; GridViewAuthors.SelectedIndex = -1; PanelPublications.Visible = false; PanelEdit.Visible = false; GridViewAuthors.DataSource = PublicationsDAL.AuthorsAll; GridViewAuthors.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { GridViewAuthors.PageSize = int.Parse(DDListNumberResults.SelectedValue); if (!IsPostBack) //only at the beginning { PublicationsDAL.AuthorsAll = PublicationsDAL.GetAuthors(); } GridViewAuthors.DataSource = PublicationsDAL.AuthorsAll; GridViewAuthors.DataBind(); PanelChangeName.Visible = false; }
protected void ButtonSave_Click(object sender, EventArgs e) { if (selectedAuthor.Id != 0 && TextBoxName.Text != selectedAuthor.Autor) //if something has changed { PublicationsDAL.UpdateAuthor(selectedAuthor.Id, TextBoxName.Text); //update view GridViewAuthors.DataSource = PublicationsDAL.AuthorsAll = PublicationsDAL.GetAuthors(); GridViewAuthors.DataBind(); foreach (var author in PublicationsDAL.AuthorsAll) { if (author.Id == (int)GridViewAuthors.SelectedValue) { selectedAuthor = new Author(author.Id, author.Autor); ShowPublications(selectedAuthor); break; } } Response.Write("<script>alert('Imię i nazwisko autora zaktualizowane')</script>"); } }