I think we're talking about three things here: 1) The grid structure itself,
2) The data shown in the grid, and 3) the data *behind* the grid.
The grid structure itself is recreated for you at each postback, whether you
AutoGenerate or add the columns yourself at design time (if you generate the
grid from scratch in code, then I believe you'd have to recreate the
structure *each* time the page loads).
The data that shows up in the grid will be retrieved from viewstate
(provided same grid has been recreated) on postback.
The data *behind* the grid (your original datasource) is gone forever,
unless you redo the query, or have saved the dataset in session, etc.
Remember that the viewstate of the grid only saves those columns that are in
the grid, and not the (possibly) larger set of columns in your original
datasource. For example, if somebody clicks on a row in your grid, you can
only get at the fields that you've shown (or hidden) somewhere on the grid.
Otherwise, you need to recreate the datasource (or the row at least).
One thing about the datagrid is that it's happy to take a null datasource,
in which case it will show no rows (and no columns if AutoGenerate is true).
What can happen is that you rebind the datagrid to the datasource, but if you
haven't rehydrated the datasource then you'll get nothing in the grid.
If there's nothing in here that helps, please repost with a little more
detail about what you're doing and when.
hth,
Bill
"Frank" wrote:
Hi all,
Assuming datagrid's viewstate is enabled, then upon
postback
1. its data will be populated automatically if
AutoGenerateCol umns is true
2. no data is populated if AutoGenerateCol umns is false.
Why does case 2 happen? How can we fixe it? I do not want
to go to the database to get the same data again.
Thanks a lot.
Frank