Monday, March 26, 2012

Suggestion for the new .NET documentation

Hello all,

I have a suggestion for the new .NET documentation.

In some newsgroup I read a posting from Anand Hegde from Microsoft. He stated that the disabling of events like PageIndexChanged on a DataGrid, when ViewState on it (or it's container) is disabled, is by design.

This is not, or very poorly, documented and I was unable to find it in the docs. Some places this should really be noted (or at least directly linked to!) is the DataGrid.ViewState documentation as well as the documentation of the other properties and events that are dependent on it.

Regards,

David van LeerdamI don't think that PageIndexChanged is disabled when viewstate is disabled, but you do have to take special steps to get paging to work properly.

See this articlePutting the DataGrid on a Diet by yours truely.
In the current version of the DataGird, the viewstate of the page must be enabled if the DataGrid's paging should work. The paging uses the viewstate to store the index of the selected page. The OnPageIndexChanged event will still be executed even if the viewstate is disabled on the page, but the page index will always be set to zero. In Whidbey the page viewstate could be disabled but the DataGrid's view state must be enabled (it's enabled by default). There is a new state (control state) for controls added to Whidbey that will let control hold their sate and will not be affected if the page viewstate is disabled.
As I mentioned in another thread, I was able to successfully port to Whidbey my demo application that shows how to do paging, sorting and selected items in a grid that has viewstate = False. The solution proposed does require that the page have viewstate enabled. The basic approach is to disable viewstate for the grid, but store current page, sortfield, selected item in the page's viewstate. I re-bind the grid on each postback, after restoring these values. I do successfully receive appropriate values for the new page index, but have to save it immediately.

0 comments:

Post a Comment