ColumnName
StringcolumnName
= DataColumn.ColumnName; DataColumn.ColumnName =columnName
;
Gets or sets the name of the column.
The following example shows how to set the name of the column:
DataColumn col = new DataColumn(); col.ColumnName = "MyColumn";
The value for the ColumnName
property can also be
set using the DataColumn
constructor as shown in
this sample:
DataColumn col = new DataColumn("MyColumn");
If the contents of the DataColumn
are output as
XML, the ColumnName
is used as the name element or
attribute tag in the XML document.
By default, ColumnName
property has no value. If
the ColumnName
property has not been set when the
column is added to the DataColumnCollection
of a
DataTable
, the column name defaults to
Column1
, Column2
, and so on.