In this chapter, I reviewed the DataGrid control’s built-in mechanism for in-place editing. You can use it most effectively when you take advantage of edit templates, which require you to use template columns but provide you with unprecedented flexibility. You also learned how to add new rows to the DataGrid control and about the serious update issues that arise.
In general, when it comes to data editing you have a couple of options to choose from, one of which is grid-based editing that mimics Microsoft Excel functionality. The second option is a more traditional approach based on separate pages, or frames, that display ad-hoc pages. Although powerful and effective, ADO.NET data binding is a sort of one-way data binding where loading is better supported than storing. In fact, ADO.NET data binding does not support server cursors, nor does it support special two-way binding between in-memory structures and database columns with automatic updates. One of the consequences of this is the lack of a general and reliable mechanism to detect the unique ID of auto-increment columns. Either you get this functionality through an extra connection to the database server, or you resort to GUID columns whenever the database makes them available. A GUID value is algorithmically proven to be unique in time and space, and more important, can be determined by the client.
Now you have a complete, annotated description of almost all the DataGrid control functionalities. Chapter 5 is about techniques for effective ASP.NET programming, with a particular emphasis on reusability and custom controls. I’ll return to grids in Chapter 6, when I illustrate practical approaches to building really advanced reports.