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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:41:27+00:00 2026-06-10T07:41:27+00:00

I am trying to update individual record in SQL table. So, I have DataGridView

  • 0

I am trying to update individual record in SQL table. So, I have DataGridView view of that table, and when some row is selected in table and Update button is clicked, new Update Form is opened.

Main Form passes DataRow row parameter to new Form, and when update is over, row is returned to Main Form. Code example is about like this in Main Form:

private void btnUpdateUser_Click(object sender, EventArgs e)
{
  //Some code to extract DataRow
  FormUpdateUsers updateUser = new FormUpdateUsers(row, new Action<DataRow>(onUserUpdated));
  updateUser.Show();
}

When Update Form finishes update, it invokes action and returns row to Main Form, as shown below.

public partial class FormUpdateUsers : Form
{

private DataRow row;
private Action<DataRow> action;

public  FormUpdateUsers(DataRow row, Action<DataRow> action)
    {
        InitializeComponent();

        this.row = row;
        this.action = action;
    }

    private void btnConfirm_Click(object sender, EventArgs e)
    {
    //Some code for updatin a database
    action.Invoke(row);
    }
}

Question is, how to insert returned row bask to DataGridView and replace the outdated one? Any suggestions?

private void onUserUpdated(DataRow row)
{
// Update DataGridView?
}
  • 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-10T07:41:29+00:00Added an answer on June 10, 2026 at 7:41 am

    You have to know which row. Do you have any id column already inside dgv (and datarow)?
    If so, then you can do:

        private void onUserUpdated(DataRow row)
        {
            int idColumn = int.Parse(row["IdColumn"].ToString());
            foreach (DataGridViewRow DGVrow in dataGridView1.Rows)
            {
                if (idColumn == int.Parse(DGVrow.Cells["IdColumn"].Value.ToString()))
                {
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        dataGridView1[i, DGVrow.Index].Value = row.ItemArray[i].ToString();
                    }
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update several rows in a table which match some criteria
Im trying to update a table with the following code. If I change WHERE
Im trying to update the contents of an element after running some php code.
its when i starting trying implementing this that i got quite stuck. some business
I have a situation where I have a SQL table which pretty much 'parents'
I am trying to update a DB table with the following structure: user_id, group_id,
I'm trying to update the records whereby I found out that I will be
I'm trying to update multiple rows in a table but due to server resources
I'm trying to do some unit testing on a project that unfortunately has high
I have an existing table of contacts that has about 140k records in it.

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.