private void Page_Load(Object sender, System.EventArgs e) { if (Page.IsPostBack == false) { if (ItemID != 0) { BooksDB bookDB = new BooksDB(); SqlDataReader dr = bookDB.GetSinglerb_BookList(ItemID); // Load first row into DataReader while (dr.Read()) { if (dr["ISBN"] != DBNull.Value) { ISBNField.Text = dr["ISBN"].ToString(); } if (dr["Caption"] != DBNull.Value) { CaptionTextBox.Text = dr["Caption"].ToString(); } CreatedBy.Text = dr["CreatedByUser"].ToString(); CreatedDate.Text = ((DateTime)dr["CreatedDate"]).ToShortDateString(); } // Close the datareader dr.Close(); } else { CreatedDate.Text = DateTime.Now.ToShortDateString(); topDeleteButton.Visible = false; // Cannot delete an unexsistent item bottomDeleteButton.Visible = false; // Cannot delete an unexsistent item } } }
private void Page_Load(object sender, System.EventArgs e) { BooksDB books = new BooksDB(); myDataList.DataSource = books.Getrb_BookList(ModuleID); myDataList.DataBind(); myDataList.RepeatColumns = Int32.Parse(Settings["Columns"].ToString()); }
override protected void OnDelete(EventArgs e) { if (ItemID != 0) { BooksDB bookDB = new BooksDB(); bookDB.Deleterb_BookList(ItemID); } this.RedirectBackToReferringPage(); }
override protected void OnUpdate(EventArgs e) { // Only Update if the Entered Data is Valid if (Page.IsValid == true) { BooksDB bookDB = new BooksDB(); if (ItemID == 0) { // Add the book within the books table bookDB.Addrb_BookList(ModuleID, PortalSettings.CurrentUser.Identity.Email, ISBNField.Text, CaptionTextBox.Text); } else { // Update the book bookDB.Updaterb_BookList(ItemID, PortalSettings.CurrentUser.Identity.Email, ISBNField.Text, CaptionTextBox.Text); } // Redirect back to the portal home page this.RedirectBackToReferringPage(); } }