Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with Rules object during save on a postback
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Problem with Rules object during save on a postback
Versions des environnements
Environment:
ASP.NET
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MySQL
Divers
Thread ID:
00987178
Message ID:
00987178
Vues:
81
After working through the Quick Start Tutorial I decided to create a simple maintenance form that creates, reads, updates and deletes a list of states. I used the technique for editing data with a databound grid (with Update/Delete/Edit) buttons embedded.

The editing of existing data works great. When the code at the top of the ASPX form reads as follows
Private Sub Page_Load()
    Session("dsStates") = Me.oStates.GetAllStates()
End Sub
As soon as the code is changed to take into account a postback situation as below:
If Not IsPostBack Then
      Session("dsStates") = Me.oStates.GetAllStates()
Else
      Dim dsStates As DataSet = CType(Session("dsStates"), DataSet)
      Me.oStates.SetCurrentDataSet(dsStates)
End If
The check rules code
Public Overrides Function CheckRulesHook() As Boolean
        Me.ValidateStateName(Me.DataRow("cName"))
        Me.ValidateStateAbbreviation(Me.DataRow("cAbbreviation"))
        Return Me.ErrorProviderBrokenRuleCount = 0
End Function
throws the following exception
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

Line 27: 
Line 28:     Public Overrides Function CheckRulesHook(ByVal ds As DataSet, ByVal tableName As String) As Boolean
Line 29:         Me.ValidateStateName(Me.DataRow("cName"))
Line 30:         Me.ValidateStateAbbreviation(Me.DataRow("cAbbreviation"))
Line 31: 
Anyone have a clue as to how the Rules Object is losing a reference to Me.DataRow() during the process of a SetCurrentDataSet() operation?

Thanks

CT
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform