title: Update GridView from a WebMethod
body: <p>I need help with something, it might be a bit complicated. I call a WebMethod that does somethings from inside a js file. One of the things it does, is that it calls some functions that are located in a class within the app_code.    </p>
  
  <p>In that class in app_code I get a GridView Control that is on my page and I need to update it, so I do this:    </p>
  
  <pre><code>ActiveGridView.DataSource = (ActiveDataTable).DefaultView;
  ActiveGridView.DataBind();    
  </code></pre>
  
  <p>The above works fine when I call the functions in app_code from a regular function, but doesn't update the grid when I call it within the WebMethod.      </p>
  
  <p>Any ideas how to solve this problem? </p>
  
  <p>Please note that I CAN'T have the WebMethod return the data and then on client side to update the grid.</p>
  
  <p><strong>Edited</strong></p>
  
  <p>Actually I am using a updatePanel, my aspx code looks like this:</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
                  &lt;ContentTemplate&gt;
                      &lt;asp:GridView ID="MappedDataGrid" runat="server" CssClass="pipesTbl"&gt;
                      &lt;/asp:GridView&gt;
                  &lt;/ContentTemplate&gt;
                  &lt;Triggers&gt;
                      &lt;asp:AsyncPostBackTrigger ControlID="btnRemove" EventName="Click" /&gt;
                  &lt;/Triggers&gt;
              &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>And again this works fine when I call the fill grid from an event on the page, but then when I call it after a webMethods calls the class in app_code that is spouse to fill the grid, it doesn't get refilled. 
  <strong>Edited again</strong></p>
  
  <p>I think the problem is with this line:</p>
  
  <pre><code>&lt;Triggers&gt;
    &lt;asp:AsyncPostBackTrigger ControlID="btnRemove" EventName="Click" /&gt;
  &lt;/Triggers&gt;
  </code></pre>
  
  <p>I tried changing it to this: </p>
  
  <pre><code>&lt;Triggers&gt;
     &lt;asp:AsyncPostBackTrigger ControlID="MappedDataGrid" EventName="DataBinding" /&gt;
  &lt;/Triggers&gt;
  </code></pre>
  
  <p>But didn't work, I am probably missing something, and since this is all new to me, I didn't know what to do. </p>
  
  <p>What should I be doing now in order to make it work as you said?</p>