DataGridView, Validation, and Performance
The orders grid is ported over a
production-sized store (200,000 orders) and made usable over a network with a default filter, server-side sort,
virtual rows (50-row blocks on demand) and a Σ row computed on the server. Validation moves out of the form into
OrderValidator, and the edit dialog shows its messages field by field through an ErrorProvider.
Run it
cd "LearnWisej-Samples/From WinForms to the Web Course/Module 5/OrderDesk.Web"
dotnet run -f net10.0 --urls http://localhost:5605
Then open http://localhost:5605. (Visual Studio: open OrderDesk.slnx, F5.) The first session of the process seeds
the 200,000-row store (about a second, ~60 MB); every later session finds it ready.
What to try
| Action | What you should see |
|---|---|
| Page load | "OrderDesk — Orders": the Open orders, newest first (1042 Northwind Traders 4,820.00 Open on top), the Σ footer with the count and total of every Open order, and the Performance panel: Rows fetched 50 (virtual) out of ~80,000 matching |
| Scroll the grid | one more block fetch per new block of 50 rows; blocks already held are not fetched again |
| Type north in the search box → Apply | a new count + Σ on the server; only Northwind Traders orders remain, still 50 rows per block |
| Status All / sort Total ↓ → Apply | the query changes; the browser sorts nothing |
| Edit… (or double-click a row) → change the status → Save | the dialog closes, a toast "Order n saved.", the grid re-counts and shows the new value |
| New order → Save without filling anything | the ErrorProvider marks Customer and PO number, "Add at least one order line." arrives as a toast, and the dialog stays open |
Where things live
Module 5/
└─ OrderDesk.Web/ the Wisej.NET 4 app (net10.0-windows;net10.0)
├─ Program.cs / Startup.cs session entry point (Application.MainPage) / Kestrel host (app.UseWisej())
├─ Domain/ Module 1 business logic unchanged, plus:
│ ├─ Services/OrderQuery.cs OrderQuery (filter · sort · page), PagedResult<T>, OrderSummary
│ ├─ Services/OrderStore.cs OrderStore.Large (200,000 orders, seeded once), LargeOrderRepository, OrderQueryService
│ └─ Services/OrderValidator.cs OrderValidator → ValidationResult (field-level)
├─ Dialogs/EditOrderDialog.cs the ported edit dialog: ErrorProvider + server-side validator
├─ Views/Ui.cs toast helper
├─ MainPage.cs / .Designer.cs the orders grid, the Σ footer and the Performance panel
└─ docs/ the lab deliverables
Runtime facts
DataGridView.VirtualMode+RowCount+CellValueNeededbehave as in WinForms; aDictionarykeyed by block start is all the caching the page needs. Column sorting is off (SortMode = NotSortable) because the grid holds a page.Form.ShowDialog()does not block in Wisej.NET: the edit dialog is shown withShowDialog((form, result) => …)and disposed in the callback.- The edit dialog edits one order line (the first); saving an order that had several lines replaces them with that line. The store is per process, so the change lasts until the app restarts.
- The payload figure is an estimate (cell text + ~96 bytes of framing per row); DevTools → Network → WS frames has the exact figure.
- The projects multi-target
net10.0-windows;net10.0, sodotnet runneeds-f net10.0(or-f net10.0-windows).