Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:
BackgroundThe UltraWebGrid can use any DataSource that implements the IList, ITypedList or IBindList Interface as well as the DataTable and DataSet.The DataTable can contain the results from a single DataBase Query and consists of rows and columns (This is sometimes referred to as Flat data as opposed to Hierarchical data which consists of more than one table and relations).IssuesMany times the UltraWebGrid needs to display only the data from a single DataBase Query or only needs to display rows and columns.SolutionThe DataTable provides an ideal container for Row/Column data.
Sample ProjectThis project is very simple. A DataTable is created and bound to the UltraWebGrid.When you press the "Bind DataTable to UltraWebGrid" button you will see something like this:Code DiscussionAll of the code relevant to this project is contained in the ButtonClick event for the "Bind DataTable to UltraWebGrid" button. It consists of the code required to create a simple DataTable and bind it to the UltraWebGrid.Declare a New DataTable with the name "Customers":
Create a New Column named "CustomerID" of type Int32 and add it to the DataTable:
Create an array of DataColumns to contain the columns of the primary key. Add the "CustomerID" column to the array and bind the array to the DataTable PrimaryKey property:
Create a New Column named "CustomerName" of type String with a MaxLength of 50 characters and add it to the DataTable:
Create a New Column named "LastOrderDate" of type Date and add it to the DataTable:
Create a new Row, populate the column values and add it to the DataTable:
Create another new Row, populate the column values and add it to the DataTable:
Bind the DataTable to the DataSource Property of the UltraWebGrid:
ReviewThis project is very straightforward and demonstrates the ease with which a DataTable can be created, populated and bound to the UltraWebGrid with very few lines of code.