I have a GridView that accesses data from a SqlDataSource in DataSet mode. I have paging enabled and it works, but on large datasets it takes an extraordinarily long time to pull data.
It seems like the SqlDatSource is pulling all the data, and then it's being paged at the UI level. This is obviously a lousy solution. I've looked at Tips on speeding up a SqlDataSource? and it seems to be on the same topic - it looks like I'll need to implement some paging code into my SELECT statement, I'm just not sure how to do that. I'm not opposed to pulling it into a SProc if I have to, but leaving the SELECT command in the SqlDataSource would be better.
I know MySQL has LIMIT X,Y (where X is number of rows to retrieve and Y is offset). TOP doesn't seem to do the same thing, and I don't know how to get the paging information from the GridView into the SqlDataSource either.
Is that the best way to do this? (And if so, where do I start?) Or is there a better way to get effective paging from a SqlDataSource in a GridView?
(I'm using C# if it matters, but I don't think it should.)
Thanks.