Exforsys.com
 
Home Tutorials VB.NET 2005
 

.NET Data Form Wizard

 

.NET Data Form Wizard - Page 2

Page 2 of 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.




First Page: .NET Data Form Wizard


Read Next: SQL Server Ad Hoc Queries



 

 

Comments


Carlos Rico U said:

  ;) Nice, thanks, for your help. Very interesting your data.
September 14, 2006, 6:52 pm

charmatz said:

  Not very helpful, much is missing in steps on page 2
June 7, 2007, 2:00 pm

Manish said:

  I think this can be done only in Visual studio.net 2003.
As You can not drag the table from server explorer in the form in Visual studio.net 2005
May 4, 2009, 1:21 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape