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 6231909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:01:14+00:00 2026-05-24T10:01:14+00:00

Technology used: .NET 2008, C#, winforms So I currently have an issue. I have

  • 0

Technology used: .NET 2008, C#, winforms

So I currently have an issue. I have a DatagridView that contains data pulled from a database. The user is supposed to be allowed to add and Delete rows as they see fit.

My problem, is that I have no idea what event is the best to use to know when a use is finished inputting, so that I can then update the DB.

I’ve tried using the events “Validated, UserAdded, RowsAdded” but the other problem I’m having, is that this DataGridView pulls from the DB, and if the user navigates to a different transaction (using a binding navigator) some of these events trigger when new data is Fetched, which defeats the purpose, because why would I update the DB right after I pulled data?

I also tried “Leave”, but another problem happens when the user clicks on the BindingNavigator to get to the next transaction. It doesn’t trigger an “enter” event, therefore not triggering “Leave” on the DataGridViw, thus, the data isn’t saved.

Also, once I get the data, it’s to be sent to service which does the actually CRUD work, so no fancy db auto update connection stuff.

Does all this make sense?

  • 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-05-24T10:01:15+00:00Added an answer on May 24, 2026 at 10:01 am

    Testing a DataGridView bound to a DataTable with rows populated run-time and changes “saved” whenever the user makes changes but does not fire when populated by code.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                DataLoad();
            }
    
            void oDataTable_RowChanged(object sender, DataRowChangeEventArgs e)
            {
                if (e.Row.RowState == DataRowState.Added)
                {
                    MessageBox.Show("A row was added");
                }
                else if (e.Row.RowState == DataRowState.Deleted)
                {
                    MessageBox.Show("A row was deleted");
                }
                else if (e.Row.RowState == DataRowState.Modified)
                {
                    MessageBox.Show("A row was modified");
                }
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                DataLoad();
            }
    
            private void DataLoad()
            {
                // simulate detached data (re)loading
                dataGridView1.DataSource = null; // make sure it's not bound before refresh
    
                // whatever queried the data and populated a table here
                DataTable oDataTable = new DataTable();
                oDataTable.TableName = "Items";
                oDataTable.Columns.Add(new DataColumn() { ColumnName = "ItemName" });
                oDataTable.Columns.Add(new DataColumn() { ColumnName = "Qty" });
    
                oDataTable.Rows.Add(new object[] { "Shirt", "1" });
                oDataTable.Rows.Add(new object[] { "Pants", "1" });
                oDataTable.AcceptChanges();
    
                // rebind gv/table
                dataGridView1.DataSource = oDataTable;
    
                // add the handler back in for user changes
                oDataTable.RowChanged += new DataRowChangeEventHandler(oDataTable_RowChanged);
    
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an ASP.NET application that takes stock price historical data from an
I have to choose a server pages technology for a few server components that
So the question is.. have you used a pre-release product or technology (a Community
Technology Used:- Asp.Net 2.0 Code:- See Below Description:- hello code given below is working
I have a mp4 file which is to be used in an application. Currently
I have a VB.NET app that is behaving strangely (or perhaps not strangely at
I have a .NET function that does some complex calculation. Depending on the parameters
What is the status of ASP.NET/MVC technology? Would there be big changes that affect
I'm currently evaluating the use of ADO.NET for a C++ application that currently uses
I would like to use a technology that is used for communication between services

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.