protected void OnDelete(object sender, EventArgs e) { //Find the reference of the Repeater Item. RepeaterItem Item = (sender as LinkButton).Parent as RepeaterItem; int id_book = int.Parse((Item.FindControl("id") as TextBox).Text); BookAppDataDataContext db = new BookAppDataDataContext(); var DeleteBook = db.BookAppDatebases.First(c => c.id == id_book); db.BookAppDatebases.DeleteOnSubmit(DeleteBook); db.SubmitChanges(); get_books = get_book(); repeaterYukle(get_books); }
protected void OnUpdate(object sender, EventArgs e) { RepeaterItem Item = (sender as LinkButton).Parent as RepeaterItem; int id_book = int.Parse((Item.FindControl("id") as TextBox).Text); string bookName = ((Item.FindControl("txtbookName") as TextBox).Text); string Writer = (Item.FindControl("txtWriter") as TextBox).Text; string PageCount = (Item.FindControl("txtPageCount") as TextBox).Text; string Categori = (Item.FindControl("txtCategories") as TextBox).Text; BookAppDataDataContext db = new BookAppDataDataContext(); var get_book = db.BookAppDatebases.Single(c => c.id == id_book); get_book.BookName = bookName; get_book.Writer = Writer; get_book.PagesCount = Convert.ToInt32(PageCount); get_book.Categories = Categori; db.SubmitChanges(); }
protected void Save_Book(object sender, EventArgs e) { BookAppDataDataContext db = new BookAppDataDataContext(); try { BookAppDatebase Book = new BookAppDatebase { BookName = (txtBookName.Text), Writer = (txtWriter.Text), PagesCount = Convert.ToInt32(txtPageCount.Text), Categories = txtCategori.Text }; db.BookAppDatebases.InsertOnSubmit(Book); db.SubmitChanges(); } catch (Exception ex) { } }