Hey guys,
Using an ultrawebgrid. No ajax or master pages, etc. The grid is set up to allow paging.
Scenario - we have a panel with a menu of image buttons. Each button allows the user to see a different set of data, so the page is being told what mode it is in and calls the appropriate method to retrieve a dataset and bind it to the grid.
The grid first gets bound to its data in the click event handler of the image button. Then it gets bound in a method called by the PageIndexChanged event handler of the grid.
Problem - If the user clicks on the image button once, the grid loads and paging works. If the user clicks on it again, no problem. So the user can keep reloading the same data all day that way and the grid loads and paging works. But, if the user sorts, then clicks the button, the code breaks where the data bind is being called from PageIndexChanged saying that the object reference is not set to an instance of an object.
I tried using grid.ResetRows in the InitializeDataSource handler, and that fixed that problem, but then paging doesn't work. I get a blank grid with a message asking for search parameters.
So, what I need is - no matter how many times the user clicks on an image button and reloads the grid, the grid must load without error and paging must work. I think the issue revolves around how the databinding is being handled, but I'm not sure how to handle it in this case.
Any ideas?
Thanks.
We figured it out. The grid has a collection of sorted columns. We just had to call the method to clear that collection whenever the grid is being bound to fresh data.