User-821857111 posted
bsurendiran
Is it good practices to have more records in the viewstate just for the sake of avoid the database calls
Absolutely not. First, you are extracting way more data than you need, and adding that to every request in an encrypted format. It will be a performance killer. A database call that gets just the records you need will not kill performance.
Depending on your SQL Server version, use either ROW_NUMBER or OFFSET and FETCH to only bring back the data you need for the grid
SQL Server 2012 Offset And Fetch:
SELECT * FROM Products ORDER BY ProductId OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY
SQL Server 2005+ ROW_NUMBER:
;WITH x AS (SELECT *, ROW_NUMBER() OVER (ORDER BY ProductID) AS rownumber FROM Products)
SELECT * FROM x WHERE rownumber BETWEEN 21 AND 30
As to your Excel issue, I would read the content into a temporary table in SQL Server (using
OPENROWSET or similar, no need for DataTables at all) and then perform the comparisons using SQL Server rather than .NET. You can find all the records that have not changed by doing a simple
join.