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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:16:47+00:00 2026-05-17T16:16:47+00:00

I have a datagrid view which shows table data from a database Environment: –

  • 0

I have a datagrid view which shows table data from a database

Environment:
– C# 4.0
– SQL Server 2005
– Visual studio 2010

What i want is: On a row to row basis automatically save changes. So when I edit the first row and then leave the row. It should save the changes to the database.

I’ve used this code:

In the From1 Load:

dataSet1.TblObject.RowChanged += rowUpdate;

The eventhandler:

private void rowUpdate(object sender, DataRowChangeEventArgs e)
{ 
    DataRow dr = e.Row;
    if (dr.RowState == DataRowState.Modified)
    {
        tblObjectTableAdapter.Update(dr);
    }
}

When I’ve edited a row in the grid, tblObjectTableAdapter.Update(dr); is called the data is stored to the table. Which is good. But the event keeps on triggering as if it’s called recursively. So the tblObjectTableAdapter.Update(dr); is causing a dataSet1.TblObject.RowChanged event. But I can’t differentiate between the both of them. I’m guessing I’m using the wrong event to store my values but I can’t find any event that sounds logical to me. What am I doing wrong?

I’ve made a dataset xsd:

TblObject

I’ve picked the dataset as datasource in this gridview:

alt text

  • 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-17T16:16:47+00:00Added an answer on May 17, 2026 at 4:16 pm

    Ok, I read your post a couple of times now, while I can’t help u directly with your problem. I’ll try anyway, What u want is that when i make a change, it doesn’t update itself immediatly, but saves the information in a list and when u press a button save the updates?

    Then You should make a List of Datarows, and each time a row is changed add that item to the list, this way the updates aren’t made directly, but only when u press the button. (This is also way better for performance sake.)

    So instead of the code

    DataRow dr = e.Row; 
    if (dr.RowState == DataRowState.Modified) 
    { 
        tblObjectTableAdapter.Update(dr); 
    }
    

    U should make

     DataRow dr = e.Row; 
        if (dr.RowState == DataRowState.Modified) 
        { 
    DatarowLst.Add(dr); 
        } 
    
    ButtonSave_Click(object sender, eventargs e)
    {
    foreach (DataRow d in DatarowLst)
    {
    tblObjectTableAdapter.Update(d); 
    }
    }
    

    EDIT:

    Ok sorry for misunderstanding u. I now understand your problem and looked into the issue.

    I found some interesting information on Data adapters and tables. It seems the Adapter does a row to row check in order to obtain information about the changes made.(i.e does it need a update or delete command?) Thereby, My GUESS is that this triggers a update to occur and therefore call your event again, and running the method recursivly.

    Info found at the REMARK piece on: This site from msdn

    They give a link to this site for more information. Maybe you’ll find your answer there.

    As to a solution for your problem it seems u can leave your event out and just call the update command. Im NOT sure about this cause I dont have time to check on this and I have little experience on this subject.

    Well, hope this helps u a bit further..

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

Sidebar

Related Questions

I have a Data Grid View inside a control that is displayed in a
I have a datagridview which im binding DataTable to. What I want do is
Say I have a DataGridView in which I dynamically build up a ComboBox column
I have a datagridview where the users can select which subset of columns to
I currently have a functioning in-house Windows Forms application which extensively uses the DataGridView
I have a DataGridView binded to this table: [Users] ID Name -- ---- 11
I have a DataGridView with one DataGridViewComboBoxColumn in my WinForms application. I need to
I have a DataGridView with its datasource set to a generic list of custom
I have a DataGridView that I want to query using Linq (C# WinForm). I
I have a DataGridView control in a winforms app that I'm working on. The

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.