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

  • SEARCH
  • Home
  • 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 190037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:13:20+00:00 2026-05-11T16:13:20+00:00

I’m so close on this one, but I need a little help. I have

  • 0

I’m so close on this one, but I need a little help. I have a simple WinForms app that uses LINQ to SQL to grab data that needs to be reviewed from a database and stuff it into a DataGridView. That part works great, but the connection I can’t seem to make is how to get the data back into the database when things change.

Here’s what I have so far:

db = new SiteDataDataContext();
src = new BindingSource();
src.DataSource = GetSitesPendingApproval(); // Returns IQueryable<Site>.
dataGridView1.DataSource = src;
dataGridView1.AllowUserToDeleteRows = true;
dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;

I have two actions I want to be able to take:

  1. When the checkbox for the boolean value IsActive (DataGridView.Columns[7]) is checked/unchecked I want changes to be sent to the database.
  2. When a record is deleted from the datagridview, I want it to also be deleted from the database.

I’m obviously missing some sort of binding, submit, merge, append, or cell changed event handler, but I haven’t been able to figure out the connection to send back the changes. If it’s easier to just make all the changes and then hit some sort of submit button to send it all back that’s fine too.

  • 1 1 Answer
  • 1 View
  • 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-05-11T16:13:21+00:00Added an answer on May 11, 2026 at 4:13 pm

    Have you tried adding an event handler for the UserDeletingRow event that uses the id on the row to remove the row from the database?

    private void DataGrid_UserDeletingRow(object sender,
                                               DataGridCommandEventArgs e)
    {
        TableCell itemCell = e.Item.Cells[0]; // assumes id is in column 0
    
        int id = int.Parse(item.Text); // assumes it's non-null
    
        using (var dc = new SiteDataDataContext())
        {
             var site = dc.Sites.Where(s => s.ID == id).SingleOrDefault();
    
             if (site != null)
             {
                 try
                 {
                    dc.Sites.DeleteOnSubmit( site );
                    dc.SubmitChanges();
                    dataGridView1.Bind();
                 }
                 catch (SqlException)
                 {
                    e.Cancel = true;
                 }
             }
         }
    }
    

    You might also provide an error message if the delete failed, but how you do it would depend on your application.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Thanks in advance for your help. I have a need within an application to
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but

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.