Implement Data-Bound Controls
There are a bunch of controls that can be bound to a data source in ASP.NET. In this section, we’ll cover the ones that sit in the Data tab in the toolbox, and are regarded as composite controls (e.g. not the DropDownList). I won’t explain every aspect and the usability of these controls, just the main differences between them. For a detailed tutorial of how to use them, visit the ASP.NET Data Access Tutorial site.
DataGrid: DataGrid is a good solution to show data in a tabular fashion, whit paging capabilities and a controllable layout with command fields, etc. However, if you are using ASP.NET 3.5 or later, you should consider using the GridView control, because it is regarded as the successor of the DataGrid.
GridView: same as the DataGrid control, it renders records from a data source, every record a row in a table. It supports massive layout personalization, like BoundField, CommandField, TemplateField, ButtonField, etc. It also supports selecting, editing and sorting data. It can be a good choice as a master table when implementing master-details scenarios. You can implement custom scenarios with a TemplateField. You can also assign templates to the GridView.
DataList: DataList is a template control, which shows the records of a data source as a list. You can predefine a template for how your data should be presented, like a FormView. The most important settings of a DataList (for the exam) are RepeatColumns, which lets you specify how many records are presented at the same time, RepeatDirection, to set how to display them, and RepeatLayout, to render the content as an HTML table, or not. Also supports selection and edit, but not in the standard manner, you must use commands to create the same effect.
Repeater: same as the DataList, but cannot set repeat direction, number of rows, etc. You can specify templates for this one, too, but it isn’t able to handle selection and editing the data. A common usage of the repeater tool is:
Notice that the BulletedList also provides a similar functionality.
DetailsView: the DetailsView control renders one record from a data source at a time, in a table form. It renders the entry in such a manner that each row represents a column in that entry. It supports paging, inserting, deleting and updating the current item. It’s very popular in master-detail scenarios, with a GridView.
FormView: the FormView is a template control, capable of rendering one entry at a time, with paging, editing, inserting and deleting. You can build up the rendering layout entirely from scratch, so it’s a good choice when you want complete control over the layout of the data presented.
ListView: displays the rows of the data source with predefined templates. Also supports edit, insert, delete, sort and paging data. A considerable feature enabled by ListView is the grouping of data.
DataPager: the DataPager allows you to add paging functionality in controls that implements the IPagableItemContainer interface, like the above mentioned ListView. To use it with this type of control, just add it to the controls layout (for example, in a template), or set the DataPager’s PageControlID to the target. The DataPager control has fields to defined templates for it, such as NextPreviousPagerField, NumericPagerField, or TemplatePagerField.
We have two data-bound controls left, which are slightly different from those mentioned above. These controls are inheriting from the HierarchicalDataBoundControl base class, and they are the Menu, and the TreeView controls. Usually you can use them to implement site navigation.
TreeView: displays hierarchical data, such as an XML document, in tree, nodes and leaves. You can use it to site navigation in conjuction with the SiteMapDataSource control, nodes set to display as hyperlinks. If you need additional information about the TreeView, visit this MSDN site.
Menu: menus can be used as data-bound controls too. The most popular scenario is to bind them to a SiteMapDataSource control. When you need some customization (such as when you want to show different menus for different roles), you can bind it to an XML file, using the DataBindings tag. Menus can (and should) be highly customized, but the names of these are so many, and speak for themselves that I wouldn’t like to explain them here. For a greater understanding of Menu controls, visit the MSDN.
I'm a software developer professionalizing in the .NET platform and iOs development. Here you can find my notes for Microsoft certifications.
Everyone who seeks, finds
- .NET (35)
- .NET 70-536 (35)
- Configuration, Diagnostic, Management and Installation Features (6)
- Globalization, Drawing and Text Manipulation (2)
- Improving the Security of a .NET Framework Application (5)
- Interoperability, Reflection and Mailing Functionality (3)
- Serialization and IO Functionality (7)
- Service Processes, Threading and Application Domains (2)
- System Types and Collections (6)
- .NET 70-536 (35)
- ADO.NET (24)
- ASP.NET (68)
- Application Architecture (1)
- ASP.NET 70-562 (44)
- PRO ASP.NET 70-564 (20)
- Design Patterns (10)
- Objective-C (4)
- Personal (4)
- Silverlight (6)
- SQL Server (43)
- 70-433 (27)
- 70-451 (16)
- WCF (8)
- Windows Azure (8)
- WPF (20)