RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Working with DataViews

Note: DB Web Controls (Borland.Data.Web namespace) are being deprecated in 2007. You should use standard Web controls instead.
With DataViews you can set filters on a DataTable using the RowFilter property or place data in a specific order. You can find the DataView component under the Data Components area of the Tool Palette. This topic discusses:
  • Runtime Properties
  • Master-Detail Relationships
  • ClearSessionChanges Method
  • DataView Limitations

At designtime, when a DBWeb control points to a DataView, the control is automatically updated whenever there is a change to any DataView property that controls the rows to be displayed. To change the DataView properties at runtime, you must make sure that the change is in place prior to the rendering of any of the DB Web Controls.  

For example, if you use a listbox to set the filter, you would also:

  • Set the listbox AutoPostback property to True.
  • Add code in the Page_Load event to handle setting the RowFilter.
  • Add code in the Page_Load event to call the ClearSessionChanges method after the RowFilter has been changed.
Assume you have two tables on a form. You bind an ASP.NET listbox to one table that contains lookup values. These values serve as a filter for the second table, whose values display in a DBWebGrid. Set the AutoPostback property in the listbox to True, handle the RowFilter setting in Page_Load, and call ClearSessionChanges after changing the RowFilter.
Tip: If you set the AutoRefresh property to False, which is the default, you might end up using cached data. Review the WorldTravel demo in \Demos\DBWeb to see an example of how this is handled.

You can make a DataView the master table in a master-detail relationship by adding a row filter. Set up a master-detail relationship with two or more DataTables within a single DataSet, then connect the DataView to the master DataTable. When the DBWebDataSource connects to the DataView, the DB Web Controls will let you select either the parent table, which is the DataView, or the detail table.

The ClearSessionChanges method notifies the DBWebDataSource that the DataSet has changed and that existing row, column, and changed data information is no longer valid. All pending changes are removed. If you try to call this method from a DBWebNavigator button click event, the DBWebNavigator button will not work.

There are some limitations with the DataView:

  • Inserted rows in a DataView behave differently than inserted rows in a DataTable.
  • A DataView does not allow multiple inserts of null records. This means that you must add data to an inserted row before adding a new inserted row.
  • If an inserted row is deleted, that row is removed from the DataView and you cannot use Undo to recall it.
  • If an inserted row contains a single non-null value, and that value is set to null, the row can be deleted in some cases and cannot be recalled.
  • DBWeb controls do not provide full support for the DataViewSort property. If a sort field is encountered, the values for the fields contained in the Sort property cannot be changed, and the insert key will be disabled on the DBWebNavigator.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!