Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
364 lines (328 sloc) 21.5 KB
<Type Name="DataKeyCollection" FullName="System.Web.UI.WebControls.DataKeyCollection">
<TypeSignature Language="C#" Value="public sealed class DataKeyCollection : System.Collections.ICollection" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit DataKeyCollection extends System.Object implements class System.Collections.ICollection, class System.Collections.IEnumerable" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.DataKeyCollection" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class DataKeyCollection&#xA;Implements ICollection" />
<TypeSignature Language="C++ CLI" Value="public ref class DataKeyCollection sealed : System::Collections::ICollection" />
<TypeSignature Language="F#" Value="type DataKeyCollection = class&#xA; interface ICollection&#xA; interface IEnumerable" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.Collections.ICollection</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.IEnumerable</InterfaceName>
</Interface>
</Interfaces>
<Docs>
<summary>Represents a collection that contains the key field of each record in a data source. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.DataKeyCollection> class represents a collection of the key fields in the data source. The key field of each record in the data source is stored in this collection. 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 <xref:System.Web.UI.WebControls.BaseDataList.DataKeyField%2A?displayProperty=nameWithType> property. This collection does not allow you 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 <xref:System.Web.UI.WebControls.DataKeyCollection.Count%2A> property to determine the number of items in the collection. To programmatically retrieve a key field from a <xref:System.Web.UI.WebControls.DataKeyCollection>, use one of following methods:
- Use the indexer to get a single key field from the collection, using array notation.
- Use the <xref:System.Web.UI.WebControls.DataKeyCollection.CopyTo%2A> method to copy the contents of the collection to a <xref:System.Array?displayProperty=nameWithType> object, which can then be used to get items from the collection.
- Use the <xref:System.Web.UI.WebControls.DataKeyCollection.GetEnumerator%2A> method to create a <xref:System.Collections.IEnumerator?displayProperty=nameWithType> implemented object, which can then be used to get items from the collection.
## Examples
[!code-aspx-csharp[BaseDataListDataKeys#1](~/samples/snippets/csharp/VS_Snippets_WebNet/BaseDataListDataKeys/CS/basedatalistdatakeyscs.aspx#1)]
[!code-aspx-vb[BaseDataListDataKeys#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/BaseDataListDataKeys/VB/basedatalistdatakeysvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.BaseDataList" />
<altmember cref="P:System.Web.UI.WebControls.BaseDataList.DataKeyField" />
<altmember cref="P:System.Web.UI.WebControls.DataKeyCollection.Count" />
<altmember cref="M:System.Web.UI.WebControls.DataKeyCollection.CopyTo(System.Array,System.Int32)" />
<altmember cref="T:System.Array" />
<altmember cref="M:System.Web.UI.WebControls.DataKeyCollection.GetEnumerator" />
<altmember cref="T:System.Collections.IEnumerator" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public DataKeyCollection (System.Collections.ArrayList keys);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Collections.ArrayList keys) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataKeyCollection.#ctor(System.Collections.ArrayList)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (keys As ArrayList)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; DataKeyCollection(System::Collections::ArrayList ^ keys);" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.DataKeyCollection : System.Collections.ArrayList -&gt; System.Web.UI.WebControls.DataKeyCollection" Usage="new System.Web.UI.WebControls.DataKeyCollection keys" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="keys" Type="System.Collections.ArrayList" />
</Parameters>
<Docs>
<param name="keys">A <see cref="T:System.Collections.ArrayList" /> that contains key fields from the data source.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this constructor to create and initialize a new instance of the <xref:System.Web.UI.WebControls.DataKeyCollection> class.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="CopyTo">
<MemberSignature Language="C#" Value="public void CopyTo (Array array, int index);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void CopyTo(class System.Array array, int32 index) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataKeyCollection.CopyTo(System.Array,System.Int32)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual void CopyTo(Array ^ array, int index);" />
<MemberSignature Language="F#" Value="abstract member CopyTo : Array * int -&gt; unit&#xA;override this.CopyTo : Array * int -&gt; unit" Usage="dataKeyCollection.CopyTo (array, index)" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.ICollection.CopyTo(System.Array,System.Int32)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="array" Type="System.Array" />
<Parameter Name="index" Type="System.Int32" />
</Parameters>
<Docs>
<param name="array">A zero-based <see cref="T:System.Array" /> object that receives the copied items from the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" />.</param>
<param name="index">The first position in the specified <see cref="T:System.Array" /> object to receive the copied contents.</param>
<summary>Copies all the items from the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" /> to the specified <see cref="T:System.Array" /> object, starting at the specified index in the <see cref="T:System.Array" /> object.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this method to copy the contents of the <xref:System.Web.UI.WebControls.DataKeyCollection> into the specified <xref:System.Array?displayProperty=nameWithType> object, starting at the specified index.
> [!NOTE]
> The `array` parameter must be a zero-based <xref:System.Array?displayProperty=nameWithType> object.
]]></format>
</remarks>
<altmember cref="T:System.Array" />
</Docs>
</Member>
<Member MemberName="Count">
<MemberSignature Language="C#" Value="public int Count { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 Count" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataKeyCollection.Count" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Count As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property int Count { int get(); };" />
<MemberSignature Language="F#" Value="member this.Count : int" Usage="System.Web.UI.WebControls.DataKeyCollection.Count" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Collections.ICollection.Count</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the number of items in the collection.</summary>
<value>The number of items in the collection.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.UI.WebControls.DataKeyCollection.Count%2A> property to determine the number of items in the collection. This property is commonly used when iterating through the collection to determine the upper bound.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="GetEnumerator">
<MemberSignature Language="C#" Value="public System.Collections.IEnumerator GetEnumerator ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance class System.Collections.IEnumerator GetEnumerator() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.DataKeyCollection.GetEnumerator" />
<MemberSignature Language="VB.NET" Value="Public Function GetEnumerator () As IEnumerator" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; virtual System::Collections::IEnumerator ^ GetEnumerator();" />
<MemberSignature Language="F#" Value="abstract member GetEnumerator : unit -&gt; System.Collections.IEnumerator&#xA;override this.GetEnumerator : unit -&gt; System.Collections.IEnumerator" Usage="dataKeyCollection.GetEnumerator " />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.IEnumerable.GetEnumerator</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Collections.IEnumerator</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Creates a <see cref="T:System.Collections.IEnumerator" /> implemented object that contains all key fields in the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" />.</summary>
<returns>A <see cref="T:System.Collections.IEnumerator" /> implemented object that contains all key fields in the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this method to create a <xref:System.Collections.IEnumerator?displayProperty=nameWithType> implemented object that can be iterated through to get each item in the <xref:System.Web.UI.WebControls.DataKeyCollection>.
Use the <xref:System.Collections.IEnumerator.Current%2A?displayProperty=nameWithType> property to get the item currently pointed to in the collection.
Use the <xref:System.Collections.IEnumerator.MoveNext%2A?displayProperty=nameWithType> method to move to the next item in the collection.
Use the <xref:System.Collections.IEnumerator.Reset%2A?displayProperty=nameWithType> method to move the enumerator to its initial position.
> [!NOTE]
> After you create a <xref:System.Collections.IEnumerator?displayProperty=nameWithType> implemented object or use the <xref:System.Collections.IEnumerator.Reset%2A?displayProperty=nameWithType> method to move the enumerator to the first item in the collection, you must call the <xref:System.Collections.IEnumerator.MoveNext%2A?displayProperty=nameWithType> method. Otherwise, the item represented by the <xref:System.Collections.IEnumerator.Current%2A?displayProperty=nameWithType> property is undefined.
]]></format>
</remarks>
<altmember cref="T:System.Collections.IEnumerator" />
<altmember cref="P:System.Collections.IEnumerator.Current" />
<altmember cref="M:System.Collections.IEnumerator.MoveNext" />
<altmember cref="M:System.Collections.IEnumerator.Reset" />
</Docs>
</Member>
<Member MemberName="IsReadOnly">
<MemberSignature Language="C#" Value="public bool IsReadOnly { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsReadOnly" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataKeyCollection.IsReadOnly" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IsReadOnly As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property bool IsReadOnly { bool get(); };" />
<MemberSignature Language="F#" Value="member this.IsReadOnly : bool" Usage="System.Web.UI.WebControls.DataKeyCollection.IsReadOnly" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value indicating whether items in the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" /> can be modified.</summary>
<value>
<see langword="false" /> for all cases.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property always returns `false` to indicate that the <xref:System.Web.UI.WebControls.DataKeyCollection> can be written to in all cases.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="IsSynchronized">
<MemberSignature Language="C#" Value="public bool IsSynchronized { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsSynchronized" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataKeyCollection.IsSynchronized" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IsSynchronized As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property bool IsSynchronized { bool get(); };" />
<MemberSignature Language="F#" Value="member this.IsSynchronized : bool" Usage="System.Web.UI.WebControls.DataKeyCollection.IsSynchronized" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Collections.ICollection.IsSynchronized</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value indicating whether the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" /> is synchronized (thread-safe).</summary>
<value>
<see langword="false" /> for all cases.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property is derived from the <xref:System.Collections.ICollection?displayProperty=nameWithType> interface and is overridden to always return `false` to indicate that the <xref:System.Web.UI.WebControls.DataKeyCollection> is not thread-safe.
For more information on the <xref:System.Web.UI.WebControls.DataKeyCollection.IsSynchronized%2A> property, see the <xref:System.Collections.ICollection.IsSynchronized%2A?displayProperty=nameWithType> property of the <xref:System.Collections.ICollection?displayProperty=nameWithType> interface.
]]></format>
</remarks>
<altmember cref="P:System.Collections.ICollection.IsSynchronized" />
<altmember cref="T:System.Collections.ICollection" />
</Docs>
</Member>
<Member MemberName="Item">
<MemberSignature Language="C#" Value="public object this[int index] { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance object Item(int32)" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataKeyCollection.Item(System.Int32)" />
<MemberSignature Language="VB.NET" Value="Default Public ReadOnly Property Item(index As Integer) As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::Object ^ default[int] { System::Object ^ get(int index); };" />
<MemberSignature Language="F#" Value="member this.Item(int) : obj" Usage="System.Web.UI.WebControls.DataKeyCollection.Item" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="index" Type="System.Int32" />
</Parameters>
<Docs>
<param name="index">The zero-based index of the key field to retrieve from the collection.</param>
<summary>Gets the key field at the specified index in the collection.</summary>
<value>The key field at the specified index in the collection.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use this indexer to get the key field from the <xref:System.Web.UI.WebControls.DataKeyCollection> at the specified index, using array notation.
## Examples
[!code-aspx-csharp[BaseDataListDataKeys#1](~/samples/snippets/csharp/VS_Snippets_WebNet/BaseDataListDataKeys/CS/basedatalistdatakeyscs.aspx#1)]
[!code-aspx-vb[BaseDataListDataKeys#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/BaseDataListDataKeys/VB/basedatalistdatakeysvb.aspx#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="SyncRoot">
<MemberSignature Language="C#" Value="public object SyncRoot { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance object SyncRoot" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.DataKeyCollection.SyncRoot" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property SyncRoot As Object" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::Object ^ SyncRoot { System::Object ^ get(); };" />
<MemberSignature Language="F#" Value="member this.SyncRoot : obj" Usage="System.Web.UI.WebControls.DataKeyCollection.SyncRoot" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Collections.ICollection.SyncRoot</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the object used to synchronize access to the <see cref="T:System.Web.UI.WebControls.DataKeyCollection" />.</summary>
<value>A <see cref="T:System.Object" /> that can be used to synchronize access to the collection.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The object returned in this implementation is the <xref:System.Web.UI.WebControls.DataKeyCollection> object itself.
For more information on the <xref:System.Web.UI.WebControls.DataKeyCollection.SyncRoot%2A> property, see the <xref:System.Collections.ICollection.SyncRoot%2A?displayProperty=nameWithType> property of the <xref:System.Collections.ICollection?displayProperty=nameWithType> interface.
]]></format>
</remarks>
<altmember cref="T:System.Object" />
<altmember cref="P:System.Collections.ICollection.SyncRoot" />
<altmember cref="T:System.Collections.ICollection" />
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.