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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:09:56+00:00 2026-05-16T20:09:56+00:00

how I can access a DataSet and it’s TablesData (s) to add/delete/edit rows from

  • 0

how I can access a DataSet and it’s TablesData(s) to add/delete/edit rows from another class

I have a WinForm and I added

  • DataGridView dataGridView1
  • DataSet dataSet1
  • bind them with BindingSource

all the data will be saved in an XML

all work OK, I made few test projects all work fine

but when I try to test the possibility to add data row from another class, it does not show the change on the DataGridView!!!!

so I have Form1 with dataGridView1 and dataSet1 both are public

within the other Class I did

var esf = new Form1();
           
DataRow pl = esf.dataSet1.Tables["MyItems"].NewRow();

pl["Type"]  = type;
pl["Name"] = true;

esf.dataSet1.Tables["MyItems"].Rows.Add(pl);

and if I add

esf.dataSet1.WriteXml(esf.XmlSettingsFile);

it saves the file correctly!

but it overwrites other data

I feel like I’m working with another DataSet that is the same as my Original one in the Form but I need to access the data in the original DataSet in the main Form

simply I need to have the dataSet1 as public static so I can access it and add edit data to it
but when I do that, Visual Studio gives me error! in the visual View of the Form!?!

any suggestions

  • 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-16T20:09:56+00:00Added an answer on May 16, 2026 at 8:09 pm

    If I understand correctly…

    1. You start the project or whatever, and use Form1 which has a DataGridView.
    2. You then run your first set of code in another class, and add some new data.
    3. If you write the XML out, you only get the new stuff, while the original stuff on Form1 is missing?

    If that is the case, then it’s pretty apparent what is going on…

    1. You start the project, which creates the Form1 object.
    2. You do whatever you are doing in Form1 to fill the DataGridView
    3. You run your first block of code, and the var esf = new Form1(); line creates a NEW instance of Form1, which is different than the original instance you’re trying to pull data from.
    4. Any code from the other class is just operating on the newly instantiated Form1, which is different than what you’re trying to access.

    My assumptions might be wrong since I obviously can’t see your code, but hopefully this helps.

    Edit – To solve the problem…

    Again, I can only speculate as to what your existing code looks like, but you can do something like this:

    Instead of trying to access the values from Form2 (or whatever the other form is), set up Form2 to have access to Form1 from the get-go:

    1. Give Form2 a public property “DataSet” or something.
    2. When instantiationg Form2 (presumably from Form1), simply do this:

      Form2 reliantForm = new Form2();

      relaintForm.DataSet = this.dataSet1;

      reliantForm.Show();

    3. Form2 now has a reference to the dataset and can manipulate it as needed.

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

Sidebar

Related Questions

I can access the database either from a .NET program (using ODBC) or through
I know you can access the Contact Store from the SDk, but is it
Is there any way i can access the page object from within the global.asax
I have an object created in a host application and can access it remotely
I have a TreeView whose contents (nested TreeViewItems) are generated from a dataset via
In PHP you can access characters of strings in a few different ways, one
Is there a way I can access (for printout) a list of sub +
does anyone know where on access 2007 a function where i can access my
I've been raised to believe that if multiple threads can access a variable, then
How do I setup TeamCity 4.0 so that I can access it over port

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.