asp.net.ph

DataKeyCollection Class

System.Web.UI.WebControls Namespace


Represents a collection of values containing the key field for each record in a data source.

DataKeyCollection Class Members

Collapse   Constructors

Visibility Constructor Parameters
public DataKeyCollection ( ArrayList keys )

Collapse   Properties

Visibility Name Value Type Accessibility
public Count Int32 [ Get ]
public IsReadOnly Boolean [ Get ]
public IsSynchronized Boolean [ Get ]
public Item ( Int32 index ) Object [ Get ]
public SyncRoot Object [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public CopyTo ( Array array , Int32 index ) Void
public GetEnumerator ( ) IEnumerator

Remarks

The DataKeyCollection class stores the key field of each record in the data source. This allows you to store the key field with a data listing control without displaying it in the control.

This collection is automatically filled with the values from the field specified by the BaseDataList.DataKeyField property. This collection is read-only, and does not allow to manually add or remove items from the collection.

The key field is commonly used in a handler for an event, such as ItemCommand or DeleteCommand, as part of an update query string to revise a specific record in the data source. The key field helps the update query string identify the appropriate record to modify.

Use the Count property to determine the number of items in the collection. To programmatically retrieve a key field from a DataKeyCollection, use one of following methods:

  • Use the indexer to get a single key field from the collection, using array notation.
  • Use the CopyTo method to copy the contents of the collection to a System.Array object, which can then be used to get items from the collection.
  • Use the GetEnumerator method to create a System.Collections.IEnumerator implemented object, which can then be used to get items from the collection.

See Also

BaseDataList Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph