protected void txtRiderSumAssured_TextChanged(object sender, EventArgs e) { TextBox thisTextBox = (TextBox)sender; this.oPolicyRider.Rules.ClearAll(); GridViewRow gvr = (GridViewRow)thisTextBox.Parent.Parent; if (this.oPolicyRider.Rules.ValidateSumAssuredMaxMin((Guid)this.oPolicyRider.DataSet.Tables[0].Rows[gvr.RowIndex]["RiderFK"], decimal.Parse(thisTextBox.Text)) != null) { // show the message somehow } this.CalculateRiderPremium(true, gvr); this.SetFocus(gvr.Cells[3].Controls[1]); }but I get an error:
Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 37: { Line 38: message = "Rider Sum Assured must be between " + oPlan.Entity.MinSumAssured.ToString() + " and " + oPlan.Entity.MaxSumAssured.ToString(); Line 39: this.AddErrorProviderBrokenRule("SumAssured", message); Line 40: } Line 41: return message; Source File: C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Business\PolicyRider\PolicyRiderRules.Partial.cs Line: 39 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] OakLeaf.MM.Main.Web.UI.mmWebDataHelper.SetControlErrorMessage(ImmWebBindingDataGrid control, mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e) +273 OakLeaf.MM.Main.Web.UI.WebControls.mmGridView.StateChangeHandler(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e) +211 OakLeaf.MM.Main.Business.mmBusinessStateChangeDelegate.Invoke(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e) +0 OakLeaf.MM.Main.Business.mmBusinessObject.OnStateChange(mmBusinessState bizState, String tableName, Object primaryKeyValue, Object[] primaryKeyValues) +174 OakLeaf.MM.Main.Business.mmBusinessObject.OnErrorProviderBrokenRuleAdd(mmErrorProviderArgs arg) +111 OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(mmErrorProviderArgs arg) +768 OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(String propertyName, String columnName, String errorText) +434 OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(String columnName, String errorText) +46 SamaanSystems.IAS.Business.PolicyRiderRules.ValidateSumAssuredMaxMin(Nullable`1 planPK, Nullable`1 sumAssured) in C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Business\PolicyRider\PolicyRiderRules.Partial.cs:39 SamaanSystems.IAS.Web.PolicyEdit.txtRiderSumAssured_TextChanged(Object sender, EventArgs e) in C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Web\PolicyEdit.aspx.cs:1244 System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e) +8739502 System.Web.UI.WebControls.TextBox.RaisePostDataChangedEvent() +55 System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +10 System.Web.UI.Page.RaiseChangedEvents() +165 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485 Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3614Although VS debugger stops on this line: