Binding a DataTable to the Grid

May 28, 2009 at 9:18 AM

Hi

Can you please provide me with the information on how can I bind a DataTable to the grid in the AjaxDataControls?

Also, I need that the columns get auto-generated from the datatable that i provide? (the datatable is returned from my web service).

 

Thanks

Akshaya

Dec 16, 2010 at 9:32 AM

You can't.

The DataTable class is very complex to be serialized into a JSON object.

Instead you can create a class to put the row informations and return a array of objects of this class in your web service.

Coordinator
Mar 31, 2011 at 1:50 PM

You actually can do it. Just return the dataTable from your webservice or pagemethod and use the below code:

datagrid.set_dataSource(dt.rows);
datagrid.dataBind();