Reputation: 9327
I am trying to bind a copy of datatable to the gridview, but it does not display it. Here is a sample code:
var cloneData = originalData.clone();
gvTable.DataSource = cloneData;
gvTable.Databind();
if I bind originalData instead of cloneData, it works.. what's wrong with the copy?
asp.net C#.
Upvotes: 0
Views: 478
Reputation: 2847
You need to use Copy()
instead of Clone()
Both the Copy and the Clone methods create a new DataTable with the same structure as the original DataTable. The new DataTable created by the Copy method has the same set of DataRows as the original table, but the new DataTable created by the Clone method does not contain any DataRows.
Upvotes: 2