c# - SubmitChanges() not work when i change datagridview -
nothing happen , nil alter when utilize datagridview , submitchanges()
private void form1_load(object sender, eventargs e) { this.book_infodatagridview.datasource = bookstore.book_info; bindingsource bds=new bindingsource(); bds.datasource = this.bookstore.book_info; this.book_infobindingsource = bds; this.book_infobindingnavigator.bindingsource = bds; } private void save_click(object sender, eventargs e) { this.book_infobindingsource.endedit(); bookstore.submitchanges(); }
i believe you're trying .submitchanges()
info in datagridview
private void save_click(object sender, eventargs e) { using (var bookstorecontext = new yourcontext()) { var b = (bookclass)bds.current; var book = bookstorecontext.products.single(c => c.bookid == b.bookid); //or .first() book.bookname = b.bookname; book.bookinfo = b.bookinfo; bookstorecontext.submitchanges(); } }
c# winforms
No comments:
Post a Comment