title: How do I Update/Reload DataGridView BindingSource?
body: <p>I am new to C#, Windows Forms, and datagridviews. I have a tabbed form: tab 1 displays a datagridview of the exercises table; tab 2 is for adding a new exercise to the table. The exercises table is bound to the datagrid view via test_ExercisesDataSet, vwexercisesBindingSource, vw_ExercisesTableAdapter.</p>
  
  <p>I'm not sure what I need to do to rebind/refresh the binding source in order to get the datagridview to refresh when I switch back to tab 1. If I completely close the form and restart it, I can see the new row in the table.</p>
  
  <p>I've seen many examples both on the Web and on StackOverflow but I still don't understand what I'm doing wrong.</p>
  
  <p>BTW, I'm using Visual Studio 2010.</p>
  
  <p>Any help is appreciated!!</p>
  
  <p>Thanks!</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Configuration;
  using System.Data;
  using System.Data.SqlClient;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace testTabbedInterface
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          public string GetConnectionString()
          {
              return connString;
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              // TODO: This line of code loads data into the 'test_ExercisesDataSet.vw_exercises' table. You can move, or remove it, as needed.
              this.vw_exercisesTableAdapter.Fill(this.test_ExercisesDataSet.vw_exercises);
              exerciseListDataGridView.DataSource = this.test_ExercisesDataSet.vw_exercises;
          }
  
          private void InsertExercise(string exerciseName, string exerciseDescription, string exerciseBegin)
          {
              var conn = new SqlConnection(GetConnectionString());
              const string InsertExerciseSql = @"INSERT INTO database.dbo.exercises
                  (PK_exerciseUID,
                  exerciseName,
                  exerciseDescription,
                  exerciseBegin,
                  exerciseEnd) 
                  VALUES 
                  (@PK_exerciseUID,
                  @exerciseName,
                  @exerciseDescription,
                  @exerciseBegin,
                  NULL)";
  
              try
              {
                  SqlCommand cmd = new SqlCommand(InsertExerciseSql, conn);
                  var param = new SqlParameter[4];
  
                  Guid exerciseGUID = Guid.NewGuid();
                  param[0] = new SqlParameter("@PK_exerciseUID", exerciseGUID);
                  param[1] = new SqlParameter("@exerciseName", exerciseName);
                  param[2] = new SqlParameter("@exerciseDescription", exerciseDescription);
  
                  //Convert date(s) to correct format
                  DateTime exerciseBeginConverted = Convert.ToDateTime(exerciseBegin);
                  param[3] = new SqlParameter("@exerciseBegin", exerciseBeginConverted);
  
                  foreach (SqlParameter t in param)
                  {
                      cmd.Parameters.Add(t);
                  }
  
                  conn.Open();
                  cmd.CommandType = CommandType.Text;
                  cmd.ExecuteNonQuery();
                  MessageBox.Show("Test/Exercise, " + exerciseName + ", successfully added!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
              }
              catch (SqlException ex)
              {
                  string msg = "Error inserting into 'exercises': ";
                  msg += ex.Message;
                  throw new Exception(msg);
              }
              finally
              {
                  conn.Close();
              }
          }
  
          private void saveExerciseButton_Click(object sender, EventArgs e)
          {
              InsertExercise(exerciseName.Text, exerciseDescription.Text, exerciseBegin.Text);
  
              this.exerciseListDataGridView.EndEdit();
  
              tabControl1.SelectTab("testExerciseTab");
          }
  
          private void addExButton_Click(object sender, EventArgs e)
          {
              tabControl1.SelectTab("exerciseTab");
          }
  
          private void reloadExListButton_Click(object sender, EventArgs e)
          {
              this.exerciseListDataGridView.Refresh();  
          }
      }
  }
  </code></pre>