asp.net.ph

DataColumn Constructor ( )

System.Data Namespace   DataColumn Class


Initializes a new instance of a DataColumn class.

[ VB ]
Public Sub New ( )

[ C# ]
public DataColumn ( );

[ C++ ]
public: DataColumn ( );

[ JScript ]
public function DataColumn ( );

Remarks

When created, a new DataColumn object has no default ColumnName or Caption. When added to a DataColumnCollection, however, a default name ( "Column1", "Column2", and so on ) is given to the column.

Example

The following example initializes a new DataColumn using this constructor, sets various properties, and adds it to a DataTable object's DataColumnCollection.

private void AddDataColumn ( DataTable myTable ) {
   DataColumn myColumn = new DataColumn ( );
   // set various properties.

   myColumn.ColumnName = "id";
   myColumn.DataType = System.Type.GetType ( "System.Int32" );
   myColumn.AutoIncrement = true;
   myColumn.AutoIncrementSeed = 1;
   myColumn.AutoIncrementStep = 1;
   myColumn.ReadOnly = true;

   // add to Columns collection.
   myTable.Columns.Add ( myColumn );
}
  C# VB

See Also

DataColumn Members   DataColumn Constructor Overload List   ColumnName   Caption   DefaultValue   DataTable   DataType 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