Data Binding, DataGridView & Data Workflows
An observable WorkOrder model
(INotifyPropertyChanged) held in a BindingList<WorkOrder> behind a Wisej.Web.BindingSource, a
DataGridView bound to it with formatted columns (currency, date, status/priority colours), a search
box and a status filter that narrow the grid through IWorkOrderService.Filter, a master-detail editor
whose fields are bound to the same BindingSource (typing updates the grid row live), dirty tracking
with an ● Unsaved changes indicator, and a Save / Discard pair that commits or rolls back through the
service.
Nothing here is deployed anywhere; it is a plain Wisej.NET 4 project that runs on your machine.
Run it
cd "LearnWisej-Samples/Production Architecture Deep Dive\Module 4\TicketOps"
dotnet run -f net10.0 --urls http://localhost:5104
Then open http://localhost:5104. (Visual Studio: open TicketOps.slnx, press F5 — the port is in
Properties/launchSettings.json.)
Requirements: .NET 10 SDK, the Wisej-4 4.1.0 NuGet package.
What to try in the Work Orders window
| Action | What you should see |
|---|---|
| (load) | the grid shows $240.00-style costs, Jun 14-style dates, coloured Status/Priority, #2005's Due cell tinted red (overdue); the editor shows Work Order 2001 |
Type pump in the search box, or pick a status | count 1 of 6 work orders; the detail follows the new current row. A search with no matches (e.g. turbine) empties the grid, disables the editor and shows a grey banner — not an error |
| Click row 2002, edit Title / Cost / Due date / Assigned to | the grid cell changes as you type (Cost as $2,150.00), the Title turns amber, ● Unsaved changes appears, Save / Discard enable |
| Status → In Progress | the Status cell text and colour change |
| Save | the indicator clears; status ● Work order #2002 saved. |
| Clear the Title (or set In Progress with no assignee), Save | orange banner Title is required.; the edit stays on screen and the row stays dirty |
| Discard (after an edit) | the fields and the row revert; ● Changes to work order #2002 discarded. |
| ↻ Reload while a row is dirty | orange banner Save or discard the unsaved changes before reloading.; nothing reloaded |
If the store throws during Save, the handler logs the details and the user sees ✖ Your changes could not be saved and are still on screen. Check the log for details. — the edits stay.
Where things live
TicketOps/
├─ Views/
│ ├─ WorkOrdersPage.cs the screen: InitializeBinding, CellFormatting, CurrentChanged → RefreshDetail, thin handlers
│ └─ WorkOrdersPage.Designer.cs GENERATED-style layout: BindingSource, grid columns by DataPropertyName, column formats
├─ Controls/StatusBanner reusable "● state" + banner UserControl (display only)
├─ Services/
│ ├─ IWorkOrderService.cs LoadAsync · Filter · SaveAsync · Discard (no UI types)
│ └─ WorkOrderService.cs validation, filter, commit (AcceptChanges) / rollback (RejectChanges), persistence orchestration
├─ Domain/
│ ├─ WorkOrder.cs observable record: INotifyPropertyChanged, IsOverdue, IsDirty snapshot; compiles without Wisej.NET
│ ├─ WorkOrderQuery.cs what the toolbar collects + the matching rule
│ └─ OperationResult.cs success / safe explanation handed back to the screen
├─ Data/
│ ├─ IWorkOrderRepository.cs persistence contract
│ └─ InMemoryWorkOrderRepository.cs fake store (copies in, copies out), the six video rows
├─ Infrastructure/
│ ├─ ILog.cs / ActivityLog.cs logging (written to the server console; details stay there)
│ └─ AppComposition.cs who gets what: one object graph per session, constructor injection, no statics
├─ Resources/Strings.cs safe user-facing messages
├─ docs/ BindingDecisions · DataWorkflow (+ .svg) · CommitCancelNotes · ReviewChecklist
├─ Program.cs Wisej.NET session entry point → AppComposition
└─ Startup.cs Kestrel host (app.UseWisej())