Getting an Object reference not set to an instance of an object when saving updates to a MM.NET Grid.
This specifically is bombing out in the Business Rules CheckRulesHook.
When my first Validate function is called the parameter Me.DataRow("CompanyOrVendorName").ToString has a value of Nothing. This is where the exception is raised.
So how can a resolve using this CheckRulesHook with the web form grid's UpdateCommand???
The Update Command code:
Private Sub LogDataGrid_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles LogDataGrid.UpdateCommand
Me.LogDataGrid.EditItemIndex = e.Item.ItemIndex
Dim dsLog As DataSet = CType(Session("dsLog"), DataSet)
Me.oLog.SaveDataSet(dsLog)
Me.LogDataGrid.EditItemIndex = -1
Me.BindControl(LogDataGrid)
End Sub
The Log BO CheckRulesHook code:
Public Overrides Function CheckRulesHook(ByVal ds As DataSet, ByVal tableName As String) As Boolean
Me.ValidateCompanyOrVendorName(Me.DataRow("CompanyOrVendorName").ToString)
Me.ValidateCompanyOrVendorAbbreviation(Me.DataRow("CompanyOrVendorAbbreviation").ToString)
Me.ValidateLogType(Me.DataRow("LogType").ToString)
Me.ValidateProject(Me.DataRow("Project").ToString)
Me.ValidateProjectName(Me.DataRow("ProjectName").ToString)
Me.ValidateProjectCityState(Me.DataRow("ProjectCityState").ToString)
Return Me.ErrorProviderBrokenRuleCount = 0
End Function
The stack trace for the exception:
NullReferenceException: Object reference not set to an instance of an object.]
OakLeaf.MM.Main.Business.mmBusinessObject.PreSaveProcessing(DataSet ds, String tableName)
OakLeaf.MM.Main.Business.mmBusinessObject.CheckRules(mmBusinessObject businessObject, DataSet ds, String tableName)
OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName, String databaseKey, IDbDataAdapter dbAdapter)
OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName, String databaseKey)
OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds, String tableName)
OakLeaf.MM.Main.Business.mmBusinessObject.SaveDataSet(DataSet ds)
ABC.MyApplicationWeb.LogTracking.LogDocuments.LogDataGrid_UpdateCommand(Object source, DataGridCommandEventArgs e) in C:\Documents and Settings\ouruser\VSWebCache\PC\MyApplicationWeb\LogDocuments.aspx.vb:110
System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e)
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e)
OakLeaf.MM.Main.Web.UI.WebControls.mmDataGrid.OnBubbleEvent(Object source, EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
THANKS
Joe Salvatore, Programmer/Analyst - The Stellar Group