winforms - CRUD with WPF, e.Row.Item and e.Row.DataContext are empty -


i'm trying build simplest crud application on windows desktop. decided go wpf on windows forms , lightswitch.

created database, generated "code first database" entity framework. put datagrid 1 table, set datasource. run - worked, can read.

added button, created click handler context.savechanges(); - ok, update works.

now, cannot create part. added

authorsdatagrid_roweditending(object sender, datagridroweditendingeventargs e) {     if (e.editaction == datagrideditaction.commit)     {         var newauthor = e.row.item authors;         context.authors.add(newauthor);         context.savechanges();     } } 

and unfortunately e.row.item (or e.row.datacontext) comes in empty. mistake?

wpf/winform crud tutorial links welcome; been googling days, haven't found one.

ok, problem solved; although original question not answered, went way - created separate button creates , adds author based on selected item:

    private void create_click(object sender, routedeventargs e)     {         var newauthor = authorsdatagrid.selecteditem authors;         context.authors.add(newauthor);         context.savechanges();         this.authorsdatagrid.items.refresh();     } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -