title: Loading Data Table dynamically in C# into JS Array
body: <p>I am trying to load my <code>dynamically generated Datatable</code> during runtime into <code>JS array</code> in javascript. But cannot pass it through webservice as only static methods can be called through javascript.How to return the datatable into javascript.</p>
  
  <p>aspx.cs file :</p>
  
  <pre><code>protected void btnRead_Click(object sender, EventArgs e)
  {
  //on button click it reads file path of excel and stores it in a string path 
  }
  
  private DataTable ReadExcelWithStream(string path)
  
  {
  //method reads the excel file and stores it in a dt
  ForJs(dt);
       return dt;
   }
  [ScriptMethod, WebMethod]
   public static DataTable ForJs(DataTable dt)
   {
  
       return dt;
   }
  </code></pre>
  
  <p>aspx file :</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
          function InsertLabelData() {
             PageMethods.ForJs(onSuccess, onFailure);
  
          }
  
               function onSuccess(dt) {
  
      //attach the table to dhtmlx grid
      }
  </code></pre>
  
  <p><strong>But the datatable is not passed to the javascript.
  How to pass the datatable to javascript from c# ?
  or any other methods to pass the datatable from c# to JS</strong></p>
  
  <p>Please Help.</p>
  
  <p>Thanks!</p>