protected void grdBookDetails_RowUpdating(object sender, GridViewUpdateEventArgs e) { objBookDetailsBEL.BookId = Convert.ToInt32(grdBookDetails.DataKeys[e.RowIndex].Value); objBookDetailsBEL.BookName = ((TextBox)(grdBookDetails.Rows[e.RowIndex].FindControl("txtBookNameEdit"))).Text.Trim(); objBookDetailsBEL.Author = ((TextBox)(grdBookDetails.Rows[e.RowIndex].FindControl("txtAuthorEdit"))).Text.Trim(); objBookDetailsBEL.Publisher = ((TextBox)(grdBookDetails.Rows[e.RowIndex].FindControl("txtPublisherEdit"))).Text.Trim(); objBookDetailsBEL.Price = Convert.ToDecimal(((TextBox)(grdBookDetails.Rows[e.RowIndex].FindControl("txtPriceEdit"))).Text.Trim()); try { int retVal = objBookDetailsBLL.UpdateBookRecord(objBookDetailsBEL); if (retVal > 0) { lblStatus.Text = "Book detail updated successfully"; lblStatus.ForeColor = System.Drawing.Color.Green; ClearControls(); grdBookDetails.EditIndex = -1; BindBookRecordsGridView(); } else { lblStatus.Text = "Book details couldn't be updated"; lblStatus.ForeColor = System.Drawing.Color.Red; } } catch (Exception ex) { Response.Write("Oops! error occured:" + ex.Message.ToString()); } finally { objBookDetailsBEL = null; objBookDetailsBLL = null; } }
public ActionResult Save(BooksDetails_BEL Book) { if (ModelState.IsValid) { if (Book.BookId > 0) { BookDetails_BLL.UpdateBookRecord(Book); } else { BookDetails_BLL.SaveBookDetails(Book); } return(RedirectToAction("Index")); } else { return(View(Book)); } }