DataList Component homepage

Other usage samples: Simple Table | Simple Flow | Header Style | Footer Style Complex Style | Repeat Columns

Here is a simple datalist bound to a collection of widgets.


DataKeyField & EditItemIndex

The DataKeyField property identifies the key field in the data source for item tracking. The EditItemIndex property specifies the zero-based index of the item in edit mode (-1 means no item is being edited). These properties are accepted for migration compatibility with Web Forms <asp:DataList DataKeyField="ID" EditItemIndex="0">.

DataKeyField: Name — EditItemIndex: -1

<DataList DataKeyField="Name"
          EditItemIndex="-1"
          Context="Item"
          ItemType="Widget">
    <ItemTemplate>@Item.Name - @Item.Price.ToString("c")</ItemTemplate>
</DataList>

Code:

<DataList Context="Item" ItemType="Widget">
  <HeaderTemplate>Simple Widgets</HeaderTemplate>
  <FooterTemplate>End of Line</FooterTemplate>
  <ItemTemplate>@Item.Name - @Item.Price.ToString("c")</ItemTemplate>
</DataList>