Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7945045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:44:14+00:00 2026-06-04T00:44:14+00:00

I am writing a C#.Net windows application using EF for communicating with SQL Express.

  • 0

I am writing a C#.Net windows application using EF for communicating with SQL Express. I have a Contacts table in my application. For editing a Contact I have called a new windows form by ShowDialogue() method and used ApplyCurrentValue method. In this form if I get the list of my contacts (using db.Contacts.ToList() method), the changes could be seen but when I close the form and want to refresh the gridview which exist in the main form, I cannot see the changes unless I restart the whole application.

here is the code for showing a new form:

NewContactForm contact = new NewContactForm();
        contact.TopLevel = true;
        contact.ShowInTaskbar = false;
        contact.ShowDialog();
        RefreshForm();
        FillGridView();

I have changed the contactToEdit object’s properties and want to save changes. So:

public void UpdateContact(Contact contactToEdit)
    {
        db.Contacts.ApplyCurrentValues(contactToEdit);
        db.SaveChanges();
    }

Now I want to show the list of contacts using this code which is in the FillGridView():

db.Contacts.ToList();

Am I missing some code? I even used db.AcceptAllChanges() but useless

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:44:15+00:00Added an answer on June 4, 2026 at 12:44 am

    Ok .. that is the solution which worked for me

    In my main form (parent scope) I refreshed the modified object using this simple code:

    db.Refresh(System.Data.Objects.RefreshMode.StoreWins, contactToEdit)
    

    and everything works nice ever after!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing picture editing windows forms application using vb.net/c#. i have a client
I have just switched from VB.Net to C# and am writing a windows application.
I'm going to be writing a Windows application using the .NET framework and C#.
I am currently writing a small application in Windows Mobile using CF.NET. The application
I am writing a windows form application in .net using C#. I am running
Perhaps you can help me. I am writing a windows application in VB.Net. My
Writing a .NET DLL how do I find Application.ProductName ? EDIT: Obviously, importing Windows.Forms
I'm writing an ASP.net application that uses Windows Identity Foundation. My ASP.net application uses
Possible Duplicate: Writing a Windows system tray application with .NET I want to develop
I am writing a C# Windows application program and I'm using an add-on for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.