Hello, I am currently doing paging via a stored procedure. Its this one. CREATE PROCEDURE sp_PagedItems ( @Page int, @RecsPerPage int )AS-- We don't want to return the # of rows inserted-- into our temporary table, so turn NOCOUNT ONSET NOCOUNT ON--Create a temporary tableCREATE TABLE #TempItems( ID int IDENTITY, Name varchar(50), Price currency)-- Insert the rows from tblItems into the temp. tableINSERT INTO #TempItems (Name, Price)SELECT Name,Price FROM tblItem ORDER BY Price-- Find out the first and last record we wantDECLARE @FirstRec int, @LastRec intSELECT @FirstRec = (@Page - 1) * @RecsPerPageSELECT @LastRec = (@Page * @RecsPerPage + 1)-- Now, return the set of paged records, plus, an indiciation of we-- have more records or not!SELECT *, MoreRecords = ( SELECT COUNT(*) FROM #TempItems TI WHERE TI.ID >= @LastRec ) FROM #TempItemsWHERE ID > @FirstRec AND ID < @LastRec-- Turn NOCOUNT back OFFSET NOCOUNT OFF
This is a standard procedure, which I found in an article. I used this procedure changed the tables, fields, added some parameters etc and it works sofar. In my asp.net page I am retrieving data from the database to build a datalist. Now the parameters which are required for the stored procedure are stored in the viewstate - not the Page or RecsPerPage parameter. Above the webform I have two links, one for next and one for prev. These links are set to something like that:page.aspx?Page=1However the problem is that since its a new http request, the user is somehow forced to reenter the data and rebind the datalist. Is there any workaround for that? Becuase otherwise the paging is useless, when the user can page. I hope you guys understand what I mean. Any help is very appreciated.Thanks