Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [249]

By Root 5356 0
ASP.NET developers. They are ItemPlaceholderID and GroupPlaceholderID. When you are using groups to represent bound items, the group placeholder is the server-side ASP.NET control that, when added to the layout template, indicates where the group will be rendered. Similarly, the item placeholder indicates where bound items will be rendered. You add the item placeholder to the item template or to the group template if you are using groups.

The key thing about the ListView control is its full support for templates and the subsequent highly flexible rendering engine. Table 11-2 lists the templates the control supports.

Table 11-2. ListView Template Properties

Property

Description

AlternatingItemTemplate

Indicates the template used to render every other bound item. If this property is not specified, all items are usually rendered using the item template. The alternating item template usually contains the same controls and content as the item, but with a different style to distinguish items.

EditItemTemplate

Indicates the template to use for editing each bound item. The edit template usually contains input controls to update the values of the bound record. An edit template should also contain buttons to save and discard changes.

EmptyDataTemplate

Indicates the template to render when the data source bound to the ListView control is empty. When this happens, the empty data template is rendered instead of the layout template. Note, though, that the InsertItemTemplate takes precedence if InsertItemPosition is not set to None.

EmptyItemTemplate

Indicates the template to render when there are no more data items to display in the last group.

GroupSeparatorTemplate

Indicates the template used to put custom content between each group in the ListView control.

GroupTemplate

Indicates the template used to create a tiled layout for the contents of the ListView control. In a tiled layout, the items are repeated horizontally in a row according to the value of the GroupItemCount property.

InsertItemTemplate

Indicates the template to use for inserting a new data item. The insert template contains input controls to gather data to initialize a new record. An insert template should also contain buttons to save and discard changes.

ItemSeparatorTemplate

Indicates the template used to specify the content for the separator between the items of a ListView control.

ItemTemplate

Indicates the template to use to render items bound to the control.

LayoutTemplate

Indicates the template to render the root container of any contents displayed through the ListView control. This template is no longer required in ASP.NET 4.

SelectedItemTemplate

Indicates the template used to render the currently selected data item.

In addition to the properties listed in Table 11-1 and Table 11-2, the ListView control has a number of data-binding properties, including DataKeyNames, DataSource, DataSourceID, and DataMember.

The DataKeyNames property specifies the fields that represent the primary key of the data source. When you set this property declaratively, you use a comma-separated list of field names. The underlying type is an array of strings. Strictly related to DataKeyNames is DataKeys. This property contains an object that identifies the unique key for each item that is currently displayed in the ListView control. Through the DataKeys collection, you can access the individual values that form the primary key for each displayed record.

DataSource and DataSourceID provide two mutually exclusive ways of bringing data inside of the control. The DataSource property represents an enumerable collection of bindable records; the DataSourceID property points to a data source control in the page that does the entire job of retrieving and binding data. Starting with ASP.NET 2.0, all data controls can be bound to a data source control, but not all of them can fully leverage the capabilities of a data source control. Only view controls such as GridView and DetailsView can, for example, update the record in the data source or

Return Main Page Previous Page Next Page

®Online Book Reader