alt
Advertisement
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow VB.NET 2005 arrow .NET Data Form Wizard
Site Search


.NET Data Form Wizard
Article Index
.NET Data Form Wizard
Page 2

.

.

Filtering Data

Filtering and sorting data is one of the most needed activity in the constructing any solution. We have so far seen data being pulled out from the table and displayed using some controls. However we have added an additional facility to navigate through the data. The usefulness of these techniques are limited if we cannot display data which are filtered and sorted. The data filtering can be done at the Server or at the application level with the dataset. Both the methods are discussed below:

.

.

Filtering With DataViews

The moment we use the DataAdapter’s fill method to populate the DataSet, we are dealing with disconnected architecture and the DataSet can be used to create DataViews. All further activities can be performed at the DataView level. This does not affect the data at the backend. This is the least network intensive and gives quicker response. The following illustration explores the process of filtering with DataViews

Click here to vew sample code

.Filtering At the Server

In some cases the user may still want to filter the data from the server and deal with the active data at all time. In such a scenario the application will be highly network hungry. But this method is useful if the user need dynamic data. Let us illustrate server side filtering :

Transforming Data with Lookups

Sometimes it is useful to display data in a user-friendly format on a Windows Form but store the data in a format that is more meaningful to the user’s program. For example, an order form for food might display the menu items by name in a list box. But the data table recording the order would contain the unique ID numbers representing the food. The user might have two tables like this:

OrderID

ItemID

Quantity

4085

12

1

4086

13

3

.
.

ID

Name

12

Potato

13

Chicken

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Property

Setting

DataSource

The table that contains information about which ID number is equivalent to which item. In the above scenario, this is ItemTable.

DisplayMember

The column of the data source table that the user wishes to display in the control. In the above scenario, this is "Name" (to set in code, use quotation marks).

ValueMember

The column of the data source table that contains the stored information. In the above scenario, this is "ID" (to set in code, use quotation marks).

.

.

 

5. In a procedure, call the System.Windows.Forms.ControlBindingsCollection.Add method of the ControlBindingsCollection class to bind the control's System.Windows.Forms.ListControl.SelectedValue property to the table recording the form input. The user can also do this in the designer instead of in code, by accessing the control's System.Windows.Forms.Control.DataBindings property in the Properties window. In the above scenario, this is OrderDetailsTable, and the column is "ItemID".

.

Master Detail

.

Creating the Master detail form is also simple using a wizard. In this case the user creates a new project and adds a database connection and also a DatasSource. After this he selects two tables that have foreign key relationships. Then he creates data sets also by binding the parent file to Grid. He then finished by adding a BindingNavigator and seting it’s dataSource property to emergency.

.

..

...

.

The following screenshot shows the output of a master detail Form we just created.

.

 

.

 

 

 

 

 

 

 

 

 

In this lesson we have learnt all about Data binding and filtering of data. In the lesson that follows we shall be focusing upon Consuming and Manipulating Data that we have bound to the controls.

4. Set the following properties. They can be set in code or in the designer.

3. Establish a data relation between the two tables. For more information, see Introduction to DataRelation Objects.

2. Connect to the user’s data source.

 

1. Add a System.Windows.Forms.ComboBox, System.Windows.Forms.ListBox, or System.Windows.Forms.CheckedListBox control to the form.

To create a lookup table

In this scenario, one table, OrderDetailsTable, stores the actual information we are concerned with displaying and saving. But to save space, it does so in a fairly cryptic fashion. The other table, ItemTable, contains only appearance-related information about which ID number is equivalent to which food name, and nothing about the actual food orders.


Trackback(0)
Comments (1)add comment

charmatz said:

  Not very helpful, much is missing in steps on page 2
June 07, 2007

Write comment

busy

 
< Prev   Next >
Sponsored Links
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape