System.Data Namespace DataView Class
Sets or retrieves a value indicating whether the new rows can be added using the AddNew method.
Script |
DataView.AllowNew [ = true | false ] |
This property accepts or returns only a boolean value: true, if new rows can be added; otherwise, false.
The following example sets the AllowNew property before adding a new row with the AddNew method.
private void AddRow ( ) {
DataTable myTable = new DataTable ( );
// code to populate DataTable here.
DataView dv = new DataView ( myTable );
dv.AllowNew = true;
DataRowView drv = dv.AddNew ( );
drv [ "ProductName" ] = "New Product Name";
}
Private Sub AddRow ( )
Dim myTable As New DataTable
' code to populate DataTable here.
Dim dv As New DataView ( myTable )
dv.AllowNew = True
Dim drv As DataRowView = dv.AddNew ( )
drv ( "ProductName" ) = "New Product Name"
End Sub |
|
C# |
VB |
DataView Members AddNew AllowDelete AllowEdit DataRowView