|The contents of this document can be freely copied and disseminated with the condition that the document retains reference to BioXing, the author and its Copyright notice. In addition, the document or any part of the document cannot be incorporated into commercial products without prior permission of BioXing and its author. BioXing retains all rights to commercial use of this document.
Table of Contents
The purpose of this document is to provide a practical guide to using Microsoft’s .NET
DataGrid. Most articles illustrate how to use the
DataGrid when directly bound to tables within a database and even though this is an excellent way to use the DataGrid, it is also able to display and manage programmatically created and linked tables and datasets composed of these tables without being bound to a database. Microsoft’s implementation has provided a rich syntax for populating and accessing rows and their cells within tables, for managing collections of tables, columns, rows and table styles and for managing inserts, updates, deletes and events. Microsoft’s Visual Studio .NET development environment provides detailed explanations and code examples for the classes, which is excellent for obtaining a quick reference to a method or property, but not for understanding how they all fit together and are used in applications.
This article will present different ways to create and manage bound and unbound tables and datasets and to bind them to
DataGrids for use by WebForms and WinForms. The different behaviors of the DataGrid depending upon whether it is in a WebForm or a WinForm will be presented. In addition, copying
DataGrid content to the clipboard, importing and exporting in XML and printing will be presented. Techniques for linking
DataGrid content to features within graphics objects to provide an interactive UI will be discussed in the last section.
The intent of this article is not to be a complete reference for all methods and members of the classes used for building Tables, Datasets and DataGrids, but to illustrate systematically how to build and manage them using their essential methods and properties. The article will also show equivalent ways for working with these entities to illustrate programming flexibility options. Once they are built the tables can be added to a database and/or the content easily extracted for updating existing database tables.
The structure and features of a table created using the DataTable class is at the heart of using the DataGrid; therefore, it will be presented first. Next the DataSet that manages collections of independent and linked tables will be presented followed by the DataGrid that displays and provides an interactive UI for its Tables and Datasets. All example code will be written in C# and the periodic table with its elements and isotopes will be used as a model and source of data.
Figure 1 is a summary view of the essential relationships between the
DataTables and their various methods and properties. This article will delve into the details of each of these components describing how to create them, to fill them with data and how they work together and thereby provide a clearer understanding of this relationship diagram.
Figure 1 DataGrid, DataSet and DataTable relationship diagram
Ph.D. in BioPhysics and over 20 years of experience in managing, architecting and hands-on developing software systems for biotechnology companies that produced cutting edge instrumentation and data systems. These include DNA and Peptide Synthesizers, cDNA, oligo and Protein microarrays and mass spectrometers used for protein sequencing.In 2001 founded BioXing (pronounced Bio-Crossing) which has architected and developed an extensible relational database repository and software system that includes Web Services, Client Workstation and Web Based applications. The system is used to track, manage, integrate and data mine disparate laboratory data, protocols and experiments and link to reference proteomic and genomic data. BioXing also does consulting and development for biotechnology companies.