asp.net.ph

DataColumn.ColumnMapping Property

System.Data Namespace   DataColumn Class


Sets or retrieves the MappingType of the column.

Syntax


Script DataColumn.ColumnMapping [ = enumValue ]

Property Value


enumValue One of the MappingType values.

The property is read/write with no default value.

Remarks

The ColumnMapping property determines how a DataColumn is mapped when a DataSet is saved as an XML document using the WriteXml method.

For example, if a DataColumn is named "customerID," and its ColumnMapping property is set to MappingType.Element, the column value will produce the following XML:

<Customers>
   <customerID>ALFKI </customerID>
   ...
</Customers>

<Orders>
   <OrderID>12345</OrderID>
   <customerID>ALFKI </customerID>
   ...
</Orders>

However, if the same column is mapped to MappingType.Attribute, the following XML is produced:

<Customers customerID="ALFKI" ... more attributes ... >
   <Order orderID="1234" ... more attributes ... />
   <Order orderID="1234" ... more attributes ... />
   ... more orders for this customer
</Customers>

Use the DataColumn constructor that contains the type argument to specify how the DataColumn is mapped when its DataSet is transformed to an XML document.

The ColumnMapping property corresponds to the constructor argument type, that decides whether a DataColumn is mapped as an XML attribute when a DataSet is transformed into XML.

Example

The following example sets the ColumnMapping type property of new DataColumn.

private void AddColumn ( DataTable myTable ) {
   // create a new column and set its properties.
   DataColumn myColumn = new DataColumn ( "myColumn" );
   myColumn.DataType = Type.GetType ( "System.String" );
   myColumn.ColumnMapping = MappingType.Element;

   // add the column the table's columns collection.
   myTable.Columns.Add ( myColumn );
}
  C# VB

See Also

DataColumn Members 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