Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataView.AddNew Method

Adds a new row to the DataView.

[Visual Basic]
Public Overridable Function AddNew() As DataRowView
[C#]
public virtual DataRowView AddNew();
[C++]
public: virtual DataRowView* AddNew();
[JScript]
public function AddNew() : DataRowView;

Return Value

A DataRowView.

Example

[Visual Basic, C#, C++] The following example uses the AddNew method to return a new DataRowView that has been added to the DataTable.

[Visual Basic] 
Private Sub AddNewDataRowView(dv As DataView)
   Dim drv As DataRowView = dv.AddNew
   ' Change values in the DataRow.
   drv("ColumnName") = "New value"
   drv.EndEdit
End Sub

[C#] 
private void AddNewDataRowView(DataView dv)
{
   DataRowView drv = dv.AddNew();
   // Change values in the DataRow.
   drv["ColumnName"] = "New value";
   drv.EndEdit();
}

[C++] 
private:
 void AddNewDataRowView(DataView* dv)
 {
    DataRowView* drv = dv->AddNew();
    // Change values in the DataRow.
    drv->Item[S"ColumnName"] = S"New value";
    drv->EndEdit();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataView Class | DataView Members | System.Data Namespace | AllowNew | DataRowView

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft