I have added the NeedDataSource sub because of the paging. it is the same as the code below.
once I hit the export sub code (gvMonthly.MasterTableView.ExportToCSV()) at any point afterwards the columns.count = 0
Dim myCommand As SqlCommand = New SqlCommand(sql, conn)
gvMonthly.DataSource = myCommand.ExecuteReader()
1 Answer, 1 is accepted
answered on 23 Mar 2017, 08:37 AM
Yes, the NeedDataSource is the correct approach. Basically, please make sure that you are not using the DataBind() method to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations. Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions: