The DataGrid WebControl provides an enormous of functionality that can be used to display and collect data in a Web application. This sample application provides a more advanced look at how the DataGrid control can be extended to create a Time Allocation System to associate employee hours with specific work codes for reporting and scheduling purposes.
The derived grid (named WeekGrid) allows data from a variable number of weeks to be captured, allows end users to insert and delete rows dynamically, has built-in validation support for data types and maximum allowed hours, as well as print functionality:
The custom grid supports multiple headers, leverages the ITemplate interface to dynamically create column templates, exposes events, handles preserving state between user posts, plus much more. So why is the grid featured on the XML for ASP.NET Developers Website given that the site focuses on XML and Web Services? Behind the scenes it leverages XML schemas to track state. The sample also demonstrates how to bind XML to the grid.
The following code demonstrates how the grid can be added into an ASP.NET Web Form. Click the "View Source Code" link below to view all of the code for the grid as well as the sample ASP.NET page: