Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

ASP.NET Data Bound Controls

By Exforsys | on September 6, 2005 |
ASP.NET 2.0

ASP.NET Data Bound Controls

In this tutorial you will learn about Data Bound Controls – The Hierarchy of Data Bound Controls, Simple Data Bound Controls, Composite DataBound Controls and Hierarchical Data Bound Controls.

The Hierarchy of Data Bound Controls

Data Bound controls are controls that are bound to data sources. Traditionally the DataGrid is the principal data bound control in ASP.NET 1.x. Though DataGrid is still supported, ASP.NET 2.0 introduces three new controls—GridView, FormView and DetailsView.

Unlike in ASP.NET 1.x, all controls descend from the BaseDataBoundControl class. It has two basic child classes DataBoundControl and HierarchicalDataBoundControl. While TreeView and Menu are examples of the latter, AdRotator, ListControls such as BulletedList, CheckboxList, DropDownList, ListBox and RadioButtonList, and CompositeDataBoundControls such as DetailsView, FormsView and GridView are examples of the former.

All Data bound controls can be classified into Simple, composite and hierarchical controls. The DataBoundControl Base class defines the common characteristics of non-hierarchical controls which share the same base class. It is inherited from the WebControl and has all the visual and style properties of the base class. Additionally it has infrastructural properties such as Context, Page and AccessKey.

DataMember property of the control selects the list of data that the control has to bind to when the DataSource contains more than one list. DataSource indicates the source of the data it has to bind to. It is imperative that the DataSource must be an object (unlike ASP.NET 1.x) that implements the IEnumerable or the IListSource interface. DataSourceId is the ID of the data source object used to retrieve data.

The DataBoundControl class has only one method—the DataBind method. This method is called when data has to be pumped out of the data source. The internal implementation of this method has been tweaked and modified to enhance performance. It takes into account the implementation of the IEnumerable based data sources but is more sophisticated in execution as it implements the new interfaces and new data source controls also.

Simple Data Bound Controls

List based user interface controls have been classified as Simple Data bound controls. ASP.NET 2.0 has two simple data bound controls—the AdRotator and the list control.

The AdRotator control retrieves information from a XML file which contains the path to the distinctive image, the URL to go to when the control is clicked and the frequency of the Ad. Arbitrary data sources are supported by the control in ASP.NET 2.0 and it is fully bound to the data source. This control has additional capability of creating popup and pop under ads apart from standard banners. It supports counters for tracking purposes and updates the ad when the counter is clicked. Each ad can be associated with a separate counter.

The BulletedList control is a new addition to list controls in ASP.NET. It can be used to create a list of formatted list items. Individual items can be specified by defining a ListItem for each object. The bulleted lists are filled in from the data source and receives the DataTable returned by a query. The DataTextField property of the control selects the column to show and the DisplayMode sets the display mode. The Hyperlink mode links the page directly to an external URL and click is handled by the browser. The LinkButton mode click is handled by the ASP.NET runtime and fires a server side event. The OnClick handler will have to be defined in this instance. The Index property of the BulletedListEventArgs class contains the base index of the clicked item. The BulletStyle property controls the customization of the bullet styles.

There is no change in the other list controls in ASP.NET 2.0.

Composite DataBound Controls

Two new base classes have been added to enhance the Composite Data bound controls. The new CompositeControl and CompositeDataBoundControl are separate classes with a similar blueprint. The CompositeControl class addresses the UI-based needs and CompositeDataBoundControl defines the common foundation for all composite data bound controls.

The CompositeDataBoundControl is an abstract class that declares and implements the Controls property. In ASP.NET 1.x the Controls property stores the references to child controls. The CompositeDataBoundControl additionally exposes the CreateChildControls property. It takes a Boolean argument and behaves in accordance with the argument taken to ignore or initialize the view state. In ASP.NET 2.0 the developer has to only call the PerformDataBinding method and all boilerplate tasks are performed and the implementation of the CreateChildControls is called to implement the building of the control tree. We shall see examples of the GridView, the DetailsView and the FormView controls a little later in this tutorial.

Hierarchical Data Bound Controls

The HierarchicalDataBoundControl class is the base class for hierarchical data bound controls such as TreeView and Menu. It is an abstract class but does not have any predefined services. It behaves like a logical container for controls that consume the hierarchical data.

The TreeView control displays a hierarchy of nodes. Each node may contain child nodes. Parent nodes can be expanded to display child nodes or collapsed. Checkboxes can be displayed next to nodes or images from an imagelist control can be displayed. Nodes can be programmatically selected or cleared.

The key properties of the TreeView control are Nodes and SelectedNodes. The Nodes property defines the top level nodes in the TreeView. The SelectedNode property sets the currently selected node.

The TreeView control binds to any data source object that implements the IHierarchicalDataSource interface. It also exposes a DataSource property of the type object which can be assigned to an XmlDataDocument or to plain XML. By default the nodes are bound to its own nodes to reflect the name of the node rather than the attribute or the inner text. The node to node association can be controlled by binding parameters. The nodes can be bound to a data source field by specifying tree node bindings. The TreeNodeBinding object defines the relationship between each data item and the node it is binding.

The Menu control is an end to end site navigation tool. It can be bound to any data source and also supports explicit list of items for simple cases. The menu items are stored in a collection and the MenuItems collection property returns all the child items of a given menu. A few static and dynamic methods are supported by this class such as selected item, submenus and mouse over items. Dynamic menus are implemented using the Dynamic HTML object model.

In this section of the tutorial we have examined in some detail the various kinds of Data Bound controls and listed out the general features of each of these controls. In the following sections we shall experiment with the implementation of these controls on the web page of a Web application.

« « ASP.NET SqlDataSource Control
Overview of SQL Server 2005 for the Database Developer » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 401 Followers
  • Popular
  • Recent
  • ASP.NET Code Directory

    August 12, 2005 - 0 Comment
  • ASP.NET Using a Grid to Display Detail Information

    September 13, 2005 - 0 Comment
  • What’s New in the .NET Framework 2.0 ?

    July 26, 2005 - 0 Comment
  • Forms Authentication in ASP.NET

    September 2, 2005 - 0 Comment
  • ASP.NET Page Object Model

    August 14, 2005 - 0 Comment
  • ASP.NET Displaying Master-Detail Data on the Same Page

    September 13, 2005 - 0 Comment
  • ASP.NET Working with Web Parts

    August 22, 2005 - 0 Comment
  • ASP.NET Managing Membership and Roles

    August 6, 2005 - 0 Comment
  • ASP.NET Server Controls

    August 15, 2005 - 0 Comment
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

    September 16, 2005 - 0 Comment
  • Application Development in .NET

    November 21, 2007 - 0 Comment
  • ASP.NET Advanced Site Functionality

    September 16, 2005 - 0 Comment
  • ASP.NET : Dynamic Image control

    September 16, 2005 - 0 Comment
  • ASP.NET Creating Web Wizards

    September 16, 2005 - 0 Comment
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

    September 16, 2005 - 0 Comment
  • ASP.NET Displaying Master-Detail Data on the Same Page

    September 13, 2005 - 0 Comment
  • ASP.NET DataBound Controls – Details View

    September 13, 2005 - 0 Comment
  • ASP.NET Using a Grid to Display Detail Information

    September 13, 2005 - 0 Comment
  • ASP.NET Adding Sorting and Paging in GridView

    September 10, 2005 - 0 Comment
  • ASP.NET GridView Filtering

    September 10, 2005 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • Application Development in .NET
  • ASP.NET Advanced Site Functionality
  • ASP.NET : Dynamic Image control
  • ASP.NET Creating Web Wizards
  • Displaying Master-Detail Data on Separate Pages in ASP.NET

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2022. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy
Necessary Always Enabled