T
tshad
I have a GridView in my pages that is very slow since I am sending all the
data back from server and letting the GridView handle the paging.
I need to change that since in one of my projects I could have a couple
thousand rows sent back.
Where does the GridView put the data when it is doing the paging?
Does it call the Sql Server each time it pages it?
I am planning to change the code so that the paging is done on the server.
My Sql would look something like:
With PagedResults AS
(
SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
OVER (ORDER BY LastName, FirstName) AS ResultSetRowNumber
FROM HumanResources.vEmployee
)
SELECT *
FROM PagedResults
WHERE ResultSetRowNumber > 40 AND ResultSetRowNumber <= 50
Where the Order By and row number would be dynamic.
Would I have to set this up as a dynamic SQL to accomplish this?
Or could I do something like:
With PagedResults AS
(
SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
OVER (ORDER BY @SortColumns) AS ResultSetRowNumber
FROM HumanResources.vEmployee
)
SELECT *
FROM PagedResults
WHERE ResultSetRowNumber > @StartRow AND ResultSetRowNumber <= @EndRow
Thanks,
Tom
data back from server and letting the GridView handle the paging.
I need to change that since in one of my projects I could have a couple
thousand rows sent back.
Where does the GridView put the data when it is doing the paging?
Does it call the Sql Server each time it pages it?
I am planning to change the code so that the paging is done on the server.
My Sql would look something like:
With PagedResults AS
(
SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
OVER (ORDER BY LastName, FirstName) AS ResultSetRowNumber
FROM HumanResources.vEmployee
)
SELECT *
FROM PagedResults
WHERE ResultSetRowNumber > 40 AND ResultSetRowNumber <= 50
Where the Order By and row number would be dynamic.
Would I have to set this up as a dynamic SQL to accomplish this?
Or could I do something like:
With PagedResults AS
(
SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
OVER (ORDER BY @SortColumns) AS ResultSetRowNumber
FROM HumanResources.vEmployee
)
SELECT *
FROM PagedResults
WHERE ResultSetRowNumber > @StartRow AND ResultSetRowNumber <= @EndRow
Thanks,
Tom