Many people try to design their web applications exactly like normal applications. If you try this, you will create interfaces that do not work well. Imagine making a windows application behave like a DOS application (WordPerfect did this with their initial Windows port). That would be an awkward interface would it not? Not only do you need to think differently about your user interface for the web, you also need to realize that the web has limitations and design around them.

One example of this is DBGrids. In a normal Delphi application, it might be considered normal to display hundreds or thousands of records in a grid. Doing such on the web will create very large HTML documents and very slow load times for the user.

Once developers realize this fact, they often ask for "Next" and "Previous" buttons and that the DBGrid be expanded to allow partial display. While this could be implemented, it would need to be implemented either to consume large amounts of memory on the server, or by constantly requiring the database which would consume less memory but would be slow. Instead of approaching it like a normal Delphi application, rethink your interface for the web.

Certainly not the only possibility, but a common one is the following technique. Instead of presenting your users with thousands of records initially, present them with a blank grid and a search field. Require your users to present some basic criteria to locate the records that they need. Using the search criteria, you can then return dozens, or just a few hundred rows. Not only is this good for bandwidth, but it is a good user interface, and will minimize the load on your database.

Allowing users to enter search criteria still allows for the possibility that the results may still number in the thousands and cause the very same problem that you were trying to avoid. To assist with this, TIWDBGrid has a RowLimit property. It defaults to 0, which means it is disabled. You can set it to a maximum value, and no matter how may rows the query returns, no more than the number in RowLimit will be returned to the user.

If you think about this, you have probably seen this technique elsewhere. Many search engines limit the number of rows that are returned. This is not only for bandwidth reasons. In most cases, the data becomes diminishingly useful after a certain number. In cases where this is not true, simply too much data is given to the user at one time and they will likely filter it anyways.

If you still decide that you do want a "paged grid" consisting of small sets of data with next / previous options you can accomplish this by setting the TIWDBGrid's StartFirst property to false and setting the RowLimit property to the number of rows you wish to display at a given time. Then by positioning the dataset before display, you can move next / previous.