I have a form in ASP .Net with a GridView.
The user enters a bar code and selects the number of days from a combo box.
The user then clicks a button that will build a DataTable to be used as the DataSource for the GridView. A DataBind is then done.
This all works fine. The results are returned and rows are inserted into the GridView.
I have code in a Sub called gridView_Sorting to sorter the rows in the GridView when a user clicks on the header. gridView_Sorting gets executed, but the first thing it attempts to do is create a DataTable based on the DataSource from the GridView.
The problem is that the DataSource is comes up as Nothing, and the DataTable cannot be built. The sort function does not work because of this.
I think the issue has to do with persisting state. I think that when the button is clicked, the page reloads and I'm losing the ability to get the DataSource of the GridView.
I need someone to do two things:
1. Send me code that fixes this issue
2. Explain to me what you did to fix the issue, and why
ASP .Net 4.0
VB .Net 4.0
.Net Framework 4.0
Visual Studio 2010