TechTalk Genome v4.2

GenomeReferenceField Class

Represents a field that displays a persistent reference as a drop-down list in a data-bound control.

For a list of all members of this type, see GenomeReferenceField Members.

System.Object
   DataControlField
      BoundField
         GenomeReferenceField

[AspNetHostingPermission(Level="Minimal", Action="InheritanceDemand", Unrestricted="False")]
[AspNetHostingPermission(Level="Minimal", Action="LinkDemand", Unrestricted="False")]
[TypeConverter(ConverterTypeName="System.ComponentModel.ExpandableObjectConverter, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
[DefaultProperty(Name="HeaderText")]
public class GenomeReferenceField : BoundField

Remarks

The GenomeReferenceField is a custom DataControlField implementation that can be used in data-bound controls such as DetailsView and GridView. Use this field implementation to display and edit persistent reference properties where the possible values can be presented in a drop-down list.

The GenomeReferenceField derives from the BoundField class, so you need to use the BoundField.DataField property to specify the name of the property that will be bound to the field.

You need to set the DataTextField property to specify which property of the referred persistent object should be used as content in the drop-down list. By default (if the ListDataSourceID property is not set), the field uses an internal GenomeDataSource that returns the entire Extent of the appropriate persistent type to fill the drop-down list. In this case, the DataValueField property is ignored.

You can set the ListDataSourceID property to explicitly bind the data source of the drop-down list to an external data source. However, in this case you should also specify the DataValueField property to bind the values of the drop-down list items to a property that returns the PersistentDataKey<T> representation of the listed persistent objects.

Example

In the following snippet, some OrderDetail items are listed in a GridView control. The GenomeReferenceField is bound to the Product property of the OrderDetail objects. The products are displayed by using the ProductName property, so the ProductName of the Product associated with the OrderDetail item is displayed for each OrderDetail. When the OrderDetail row is in edit mode, the field displays a drop-down list with all Products and the currently associated Product is selected. Null references in the drop-down list are not supported, so the Product reference of the OrderDetail cannot be set to null.

          
  <asp:GridView ID="OrderDetailsRelationGridView" runat="server" 
      AllowPaging="True" AllowSorting="True" 
      EmptyDataText="No item selected"
      AutoGenerateColumns="False" 
      DataKeyNames="datakey" 
      DataSourceID="OrderDetailsRelationDataSource">
    <Columns>
      <genomeControls:GenomeReferenceField DataField="Product" HeaderText="Product" SortExpression="Product.ProductName" ReadOnly="False" InsertVisible="True" AllowNullReference="False" DataTextField="ProductName" NotAnObjectSelectable="False" ValidationGroup="OrderDetailsRelationGridView" />

      <asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" SortExpression="UnitPrice" ReadOnly="False" InsertVisible="True" />
      <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" ReadOnly="False" InsertVisible="True" />
      <asp:BoundField DataField="Discount" HeaderText="Discount" SortExpression="Discount" ReadOnly="False" InsertVisible="True" />
      <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" ValidationGroup="OrderDetailsRelationGridView" />
    </Columns>
  </asp:GridView>

        

Requirements

Namespace: TechTalk.Genome.Extensions.Web.UI.Controls

Assembly: TechTalk.Genome.Extensions.Web (in TechTalk.Genome.Extensions.Web.dll)

Version: 4.2.4.4

Editions: Professional, Evaluation, Express

See Also

GenomeReferenceField Members | TechTalk.Genome.Extensions.Web.UI.Controls Namespace