title: How auto update pageload using Sqldependency
body: <p>I am trying to create and run a sqldependency method from a web form class, where I have a "UpdateMethod", which I implemented using a window-form as reference.<br>
  However the web-form version of the method, does not update the page-load automatically on the client-side, when there is a change in the database, whereas window-form does. </p>
  
  <p>Window form method version:</p>
  
  <pre><code>   delegate void GridDelegate(DataTable table);      
     private void UpdateGrid()
      {
          string sql = "SELECT * FROM [dbo].[User]";
          DataTable dt = new DataTable();
          using (SqlConnection con = new SqlConnection(connectionstring))
          {
              using (SqlCommand cmd = new SqlCommand(sql, con))
              {
                  con.Open();
                  dep = new SqlDependency(cmd); //Passing Command to SQL dependency 
                  dep.OnChange += dep_OnChange;
                  using (SqlDataReader rdr = cmd.ExecuteReader())
                  {
                      dt.Load(rdr);
                  }
              }
          }
          dataGridView1.Invoke((GridDelegate)delegate(DataTable table)
          { dataGridView1.DataSource = table; }, dt);
      }
  </code></pre>
  
  <p>Web form version of the method:</p>
  
  <pre><code>      private void UpdateGrid()
      {
          string sql = "SELECT * FROM [dbo].[User] order by uploadDate desc";
          DataTable dt = new DataTable();
          using (SqlConnection con = new SqlConnection(GetConnectionString()))
          {
  
              try 
              {
                  using (SqlCommand cmd = new SqlCommand(sql, con))
                  {
                      con.Open();
                      SqlDependency dep;
                      dep = new SqlDependency(cmd); //Passing Command to SQL dependency 
                      dep.OnChange += dep_OnChange;
  
                      using (SqlDataReader rdr = cmd.ExecuteReader())
                      {
                          dt.Load(rdr);
                          // GridView1.DataSource = rdr;
                      }
  
                  }
  
              }
  
              catch (Exception ex)
              {
                  throw ex;
              }
          }
          GridView1.DataSource = dt;
          GridView1.DataBind();
      }
  </code></pre>
  
  <p>I tried adding in a try..Catch statement in the web form version, but I am getting no errors from it.  Please advice, in how I can test this method further, in order to resolve this issue. Any hints/advice would be most appreciated.  Thank you</p>