Matt Lemos

Matt Lemos

  • NA
  • 1
  • 2.4k

Updating dataGridview when save button is clicked

Jul 27 2010 3:08 PM
Hi,

C# VS newb here... i am learning this in college and my teacher kind of sucks so i can't ask him lol but i'm having a problem figuring something out.

Okay so i have a windows form application and i have created a gridview that takes information for a dataset that i created in mssql. so i have my main form that shows the gridview then a button that goes to a new form that has the Data Source table details to input information into the table.

So that works completely fine i can view the gridview i can add data to the table when i save but the problem is when i save the new information to the dataset it's not visible right away so basically i want when i save the data for it to update the gridview right away i've temporarily solved the situation by putting a refresh button on the main form that does this

private void _btnRefresh_Click(object sender, EventArgs e)
{
this.gasTableAdapter.Fill(this.finalAssignmentDataSet.Gas);
}

so basically the other form thats adding the information to begin with to do that function with the save button.

Sorry if my explanation isn't that good it's my first time posting on a forum for programming help just let me know if you need more information.

Thanks,
Matt

EDIT**

the form with the save button has this code

 private void gasBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
Form1 mainform;
this.Validate();
this.gasBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.finalAssignmentDataSet);
//I want to add this command but it doesn't update the gridview

this.gasTableAdapter.Fill(this.finalAssignmentDataSet.Gas);
 }


Answers (2)