The formatting of the data that you want to display in the GridView is essentially determined by the source from which the data originates. The sources are seen above all:
For data from a database table, you should use the proven combination of the two components DataSource and DataBrowser to display the data. You can also sort the data in the DataBrowser column by column and in a flash.
Figure 17.7.1.1: Displaying DB data in the DataBrowser
A recommendation for very large amounts of data can be considered: Try to store the data in a string array of individual records or in a two-dimensional array. You are then able to fill the GridView very quickly with the data from the array using the GridView_Data event. If only a few rows in the GridView have to be filled with data with a small number of columns, you can, for example, insert the data to be displayed row by row - column value for column value - into the grid.
Die Aufbereitung der Daten, die Sie in der GridView anzeigen wollen, wird im wesentlichen durch die Quelle bestimmt, aus der die Daten stammen. Als Quellen werden vor allem gesehen:
Bei Daten aus einer Datenbank-Tabelle sollten Sie auf die bewährte Kombination aus den beiden Komponenten DataSource und DataBrowser setzen, um die Daten anzuzeigen. Außerdem können Sie die Daten im DataBrowser spaltenweise sortieren und das blitzschnell.
Abbildung 17.7.1.1: Anzeige von DB-Daten im DataBrowser
Als Empfehlung für sehr große Datenmengen kann gelten: Versuchen Sie die Daten in einem String-Array aus einzelnen Records oder in einem zweidimensionalen Array zu speichern. Sie sind dann in der Lage mit Hilfe des GridView_Data-Events die GridView mit den Daten aus dem Array sehr schnell zu füllen. Sind nur wenige Zeilen in der GridView mit einer geringen Anzahl von Spalten mit Daten zu füllen, dann können Sie zum Beispiel die anzuzeigenden Daten auch zeilenweise – Spaltenwert für Spaltenwert – in das Gitter einfügen.