title: Populating Gridview Using Ajax
body: <p>i have two gridview. on click of one row of one grid i have to populate another gridview. so onClientclick javascript function i called ajax which returns datatable for populating another grid. Now i am stuck how to bind grid view using javascript.</p>
  
  <p>here is code</p>
  
  <pre><code>&lt;asp:gridview id="gridview1"&gt; .....&lt;/asp:gridview&gt;
  &lt;asp:gridview id="gridview2"&gt; .....&lt;/asp:gridview&gt;
  </code></pre>
  
  <p>codebehind</p>
  
  <pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
               LinkButton db = (LinkButton)e.Row.Cells[0].Controls[0];
  
          db.OnClientClick = "FunPopulateSecondGrid(" + CType(CType(e.Row.DataItem, System.Data.DataRowView).Row, Label).text + ");"
              }
  }
  </code></pre>
  
  <p>javascript</p>
  
  <pre><code>function FunPopulateSecondGrid(productid)
  {
     $.ajax({
              url : '...',
              data : { getExEmpList: true, SelectedShop : selectedShop, ajaxCall : true },
              method : 'GET',
              dataType : 'json',
              contentType: "application/json; charset=utf-8",
              success : function(data) {
  // i am stuck here how to bind it
  //gridview2.datasource= data
  //gridview2.databind()              
              },
              error : function(xhr, status) {
                  alert('Sorry, there was a problem while placing your ajax request. Contact Admin!');
              }
          });
  }
  </code></pre>