public virtual DataRow NewRow(object defaultValues) public virtual DataRow NewRow(string tableName, object defaultValues) public virtual DataRow NewRow(DataSet ds, string tableName, object defaultValues) public virtual DataRow NewRow(DataView dv, object defaultValues)And in VB .NET:
Public Overridable Function NewRow(defaultValues As Object) As DataRow Public Overridable Function NewRow(tableName As String, defaultValues As Object) As DataRow Public Overridable Function NewRow(ds As DataSet, tableName As String, defaultValues As Object) As DataRow Public Overridable Function NewRow(dv As DataView, defaultValues As Object) As DataRow
public class OrderDefaultValues { public int CustID = 0; public int ProductID = 0; public OrderDefaultValues(int custID, int productID) { this.CustID = custID; this.ProductID = productID; } }And in VB .NET:
Public Class OrderDefaultValues Public CustID As Integer = 0 Public ProductID As Integer = 0 Public Sub New(custID As Integer, productID As Integer) Me.CustID = custID Me.ProductID = productID End Sub 'New End ClassNotice the constructor method accepts parameters that can be used to pass default values when instantiating the class. The next section shows how you can pass these parameters during instantiation.
oOrder.NewRow(new OrderDefaultValues(1009, 111160));
And in VB .NET:oOrder.NewRow(New OrderDefaultValues(1009, 111160))
Notice in this call to the NewRow method that a new instance of OrderDefaultValues is passed as a parameter. In the constructor of OrderDefaultValues, the customer ID 1009 and product ID 111160 are passed as parameters. As shown in the code at the beginning of this topic, these values are then stored to the CustID and ProductID public fields of theOrderDefaultValues object.public class Orders : ABusinessObject { protected override void HookSetDefaultValues(System.Data.DataRow dataRow) { // Cast the DefaultValues object to the custom type OrderDefaultValues Defaults = (OrderDefaultValues)this.DefaultValues; // Store the default values in the new DataRow dataRow["CustomerID"] = Defaults.CustID; dataRow["ProductID"] = Defaults.ProductID; } }And in VB .NET:
Public Class Orders Inherits ABusinessObject Protected Overrides Sub HookSetDefaultValues(dataRow As System.Data.DataRow) ' Cast the DefaultValues object to the custom type Dim Defaults As OrderDefaultValues = CType(Me.DefaultValues, OrderDefaultValues) ' Store the default values in the new DataRow dataRow("CustomerID") = Defaults.CustID dataRow("ProductID") = Defaults.ProductID End Sub End ClassNotice the HookSetDefaultValues method receives a DataRow parameter. The business object's NewRow method automatically calls this hook method when a new row is added, passing the new row as a parameter.