Let's suppose that I have created a function that creates a DataTable and adds columns to that DataTable. Next let's suppose that I have created a function that adds a row of data to that DataTable. Finally I have a funtion that binds this DataTable to a DataGrid.
I can then populate that datagrid from the row contained in this DataTable. The problem is: If I call the function to add another row to the DataTable (after the postback caused by DataBind) then ASP.NET seems to have forgotten the structure of the DataTable.
I have declared the DataTable and DataRow globally to the class. I am almost certain the problem is related to the pastback event. I can add rows to this table all day, so long as I only call the DataBind function at the end. Does anyone have any ideas?
the problem is that the datatable is not being persisted after the postback...even though you declared it at the form level it does not persist on post back. You'll have to cache the datatable in cache or session to be able to access it on the postback without
hitting the database again.
cclements
Member
70 Points
14 Posts
Lost reference to DataTable after PostBack
Oct 06, 2003 03:27 PM|LINK
TheNige
Participant
1475 Points
295 Posts
Re: Lost reference to DataTable after PostBack
Oct 06, 2003 08:30 PM|LINK