asp.net.ph

DataColumn.ReadOnly Property

System.Data Namespace   DataColumn Class


Sets or retrieves a value indicating whether the column allows changes once a row has been added to the table.

Syntax


Script DataGridColumn.ReadOnly = [ true | false ]

Property Value

true if the column is read only; otherwise, false. The default is false.

Exceptions


Exception Type Condition
ArgumentException Occurs when the property is set to false on a computed column.

Example

The following example initializes a DataColumn and sets its ReadOnly property true.

private void AddColumn ( DataTable myTable ) {
   // add a DataColumn to the collection and set its properties.
   DataColumn myColumn;
   // the constructor sets the ColumnName of the column.
   myColumn = myTable.Columns.Add ( "Total" );
   myColumn.DataType = System.Type.GetType ( "System.Decimal" );
   myColumn.ReadOnly = true;
   myColumn.Expression = "UnitPrice * Quantity";
   myColumn.Unique = false;
}
  C# VB

See Also

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