gridView.DataSource as DataTable is setting a null in asp.net

Viewed 26695

I am setting my gridview.datasource into a datatable variable as below:

DataTable dt = gvPaymentHistory.DataSource as DataTable;  

The gvPaymentHistory.DataSource has a record, however, the dt is null after that line has executed. How can I pass the Datasource records to dt?

EDIT

DataSource is List collection of a class object. It's not a DataSet

3 Answers
Related