I have a large data table containing articles published by staff to the corporate website. Users can select or not select various filters such as author and publish date, and press the Search button. The results are displayed on a paged
The underlying mechanism is that when the button is clicked, a SELECT string is generated using the filter criteria. If a filter is empty (say, the "Author" textbox is left blank) then the filter is not used. The
SelectParameters property of the grid's associated
SqlDataSource control is cleared and reset with the requested filters, the source's
SelectCommand property is set with the new query, and the grid is bound. The page then displays the first page of data. All working exactly as expected.
The problem comes up when the user tries to navigate to a different page of data. There is a postback and the data is not reloaded, resulting in an empty grid. The behavior I want is that paging through the data will page through the data.
I understand the problem: the data is not persisting between loads. I suspect there is a straightforward way to manage this, but I haven't been able to figure that out yet. I have looked at reloading the data and manually setting
PageIndex, but I haven't been able to figure out how to retrieve the requested page index.