locked
WCF Data Service(EF 4.0) + DataGridView Right way to save data RRS feed

  • Question

  • Hello everybody!

    Framework 4.0

    I created simple WCF Data Service(EF 4.0), and try to save data from WinForms DataGridView through BindingSource.

    Look at the source code.

    When I change data in DataGridView andpress table_1BindingNavigatorSaveItem button, nothing happens.

    But if I press ProgramAddBtn button all works fine.

    Where is my mistake?

    What is the right way to save data from DataGridView To WCF Data Service?

    Thanks.

           TestEntities _testEntities = new TestEntities(new Uri("http://localhost:49377/WcfDataService1.svc/"));
            
            public Form1()
            {
                InitializeComponent();
    
                table_1BindingSource.DataSource = _testEntities.Table_1;
                table_1BindingSource.AllowNew = true;
            }
    
    
            private void table_1BindingNavigatorSaveItem_Click(object sender, EventArgs e)
            {
                table_1BindingSource.EndEdit();
                _testEntities.SaveChanges();
            }
    
            private void ProgramAddBtn_Click(object sender, EventArgs e)
            {
                _testEntities.AddToTable_1(new Table_1(){id = Guid.NewGuid(),SomeText = "bla bla bla1"});
                _testEntities.SaveChanges();
            }
    • Edited by its_dens Friday, February 10, 2012 3:10 AM add EF 4.0
    Thursday, February 9, 2012 2:13 PM