WebGrid.NET Enterprise 5.0 boosts developer's productivity by introducing various ways to connect to a DataSource control in design-time through rich designers and wizards.'
SmartTag Action Panel
The easiest way to start with data binding is through SmartTag Action Panel. By default, when you drop a new instance of WebGrid to designer, the SmartTag will appear automatically as shown in the following image.
The Choose Data Source dropdown enables you to quickly connect to a DataSource control available in the web page. The dropdown will list all valid DataSource controls. You can also click on <New data source...> item to create a new DataSource control from scratch. This feature is reflected directly to DataSourceControlID property of WebGrid.
When connected to a DataSource control that supports multiple views such as in ISDataSource control, the View Names dropdown will list available views defined in the specified DataSource control such as shown in above image. This feature is reflected directly to DataMember property of WebGrid. |
Retrieve Structure and Hierarchical Structure Context Command
When you have modification to DataSource schema which is already assigned to WebGrid, you do not need to change the DataSourceControlID or DataMember property. Instead, you can simply re-retrieve the schema (structure) by using the commands in control's context menu. Refer to the following image for details.
Note that if the existing WebGrid already has structures defined such as Columns, GroupColumn, SortColumns etc - the Retrieve Structure and Retrieve Hierarchical Structure will override existing structure with new schema defined in the DataSource control. |
Flat table DataSource control
When the WebGrid is connected to flat DataSource control, such as AccessDataSource or SqlDataSource control, the WebGrid DataSource Connect wizard dialog box will appear, such as illustrated in the following image.
The DataSource connection wizard integrates deeply with Visual Studio 2005® to provide rich design-time experience, such as automatic DataSource detection when the DataSourceID property has changed. The wizard also has the ability to retrieve the DataSource schema available in the DataSource control. |
XML DataSource control
WebGrid V5.0 exclusively supports XmlDataSource control and display the XML data as hierarchical Grid to simulate TreeView. For more information about XmlDataSource control support in WebGrid V5.0, see Advanced DataSourceControl support.
When connected to an XMLDataSource control in design-time through either SmartTag Action Panel or Property Window, the XMLDataSource Connect wizard will be displayed as shown in following image.
The XmlDataSource Connect wizard has two primary features:
- Auto retrieve schema.
WebGrid simulates the TreeView display by using its Hierarchical and ChildTables feature. This option allows WebGrid to inspect the XmlDataSource schema, read and translate it to nested ChildTables in WebGrid control.
It is recommended to check this option as default. - Auto configure as TreeView.
WebGrid provides many settings and flexibility to customize appearance. With this option checked, WebGrid automatically configures its appearance so it looks like a TreeView control.
Several notes related to XmlDataSource control support:
- The TreeView support in WebGrid V5.0 is provided as basic complimentary feature to DataSource control only. It is not intended to be as used as TreeView's replacement. For more advanced TreeView-specific functions, please use Intersoft's WebTreeView for ASP.NET 2.0 instead.
- WebGrid simulates the TreeView support by loading all XML Data at first load. In this case, all Tree nodes are rendered at once in first request and no load-on-demand is necessary. Simply put, the WebGrid is working as Unbound mode.
- With its Unbound mode behavior limitation, data-related features - such as Sorting, Filtering, Paging, Editing and others - are not supported and should be disabled. However, Grouping is exclusively supported, and can be enabled.
- WebGrid is treating each XmlAttribute of a Node as Column. The auto-generated schema always assumes first attribute to be used as display text in the Tree. To change the column to be used as display text, simply moves the designated column to first column and sets its Visible property to True. Other columns Visible should be set to False. You may also want to set the first column's width to 100% to properly simulate TreeView display.
Hierarchical DataSource control
Similar to flat-view DataSource control and XMLDataSource control, WebGrid automatically displays DataSource Connect wizard when a valid multi-view (hierarchical) DataSource control is assigned to WebGrid.
The following image shows the wizard for Hierarchical DataSource control connection.
When connected to a valid hierarchical DataSource control, WebGrid allows you to perform the following actions in designer:
- Select a view available in the View Names dropdown as WebGrid's RootTable. The selection of the view in RootTable determines and affects the hierarchical child tables that will be automatically retrieved.
- Retrieve hierarchical structure. This option is enabled when WebGrid detects a valid hierarchical DataSource control being assigned. When selected, WebGrid automatically retrieves the child tables based on the relationship definition that specified in the associated dataset. The child table retrieval starts from the table view that assigned as RootTable (see option 1 above).
In order for Retrieve Hierarchical Structure to work successfully, ensure you have defined the table's relationship properly using DataSet Designer. |
Other Resources
Walkthrough Topics
How-to Topics