I am trying to load my dynamically generated Datatable
during runtime into JS array
in javascript. But cannot pass it through webservice as only static methods can be called through javascript.How to return the datatable into javascript.
aspx.cs file :
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;
}
aspx file :
<script type="text/javascript">
function InsertLabelData() {
PageMethods.ForJs(onSuccess, onFailure);
}
function onSuccess(dt) {
//attach the table to dhtmlx grid
}
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
Please Help.
Thanks!