dynamic gridview refresh

I have a gridview that is created dynamically in the back end of the code. The gridview is populated depending on the data entered into the form. When the submit button is selected the gridview is populated with the results, however when the user fills the form in the second time and selects the submit button the results in the gridview do not change. I'm not sure how I can rebind the gridview as it is dynamically created and placed in a <div> on the front end.
Below is the code I use to create the gridview

datasource is a datatable that I am using to hold the data and bind it to the gridview. Because the code is dynamic and is based on stored procedures datasource is set in two different ways depending on the format that the data is sent back to the system from the db. One of the ways data is returned is with two tables, one which contains formatting information and another which contains the data, when it's this way datasource is created like

I'm not 100% sure without seeing the full code whether it is actually an issue of checking if the page is posted back or if it is more of an issue of not retaining the data source.

I created the following test based on your code which simply populates the DataSource with one record the very first time and adds it to a session variable. Then when page is submitted via a button, a routine is run to add another row after first determining whether to get the DataSource from session or to create a new one. Each time however the grid is recreated. This seems to work but not sure if this answers your problem. The following is the test code: