Heute habe ich nach ein paar Änderungen an einem funktionierenden ASPxGridView-Steuerelement auf einmal folgende Fehlermeldung erhalten, sobald der Anwender auf einen Hyperlink im Grid oder zum Sortieren auf eine Spalte geklickt hatte:
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 65: <dxgv:GridViewDataColumn Caption=“Actions“ VisibleIndex=“4″>
Line 66: <DataItemTemplate>
Line 67: <asp:LinkButton runat=“server“ Visible='<%#Eval(„CanContinue“)%>‘ OnCommand=“GridLinkButton_Click“ CommandArgument='<%# Eval(„ID“) %>‘ CommandName=“Continue“ Text=“Continue“ />
Line 68: <asp:LinkButton runat=“server“ Visible='<%#Eval(„CanFinish“)%>‘ OnClientClick=“javascript:return confirm(‚Do you really want to finish this test run?‘);“ OnCommand=“GridLinkButton_Click“ CommandArgument='<%# Eval(„ID“) %>‘ CommandName=“Finish“ Text=“Finish“ />
Line 69: <asp:LinkButton runat=“server“ Visible='<%#Eval(„CanDetails“)%>‘ OnCommand=“GridLinkButton_Click“ CommandArgument='<%# Eval(„ID“) %>‘ CommandName=“Details“ Text=“Details“ />Source File: c:\Users\ukeim\Documents\Visual Studio 2010\Projects\Zeta Test\Zeta Test Main\Source\WebMain\UI\TestPlansAndRuns\TestRuns\CurrentTestRuns.aspx Line: 67
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP.ui_testplansandruns_testruns_currenttestruns_aspx.__DataBinding__control25(Object sender, EventArgs e) in c:\Users\ukeim\Documents\Visual Studio 2010\Projects\Zeta Test\Zeta Test Main\Source\WebMain\UI\TestPlansAndRuns\TestRuns\CurrentTestRuns.aspx:67
System.Web.UI.Control.OnDataBinding(EventArgs e) +91
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92
System.Web.UI.Control.DataBind() +15
System.Web.UI.Control.DataBindChildren() +201
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
DevExpress.Web.ASPxGridView.GridViewBaseTemplateContainer.DataBind() +20
DevExpress.Web.ASPxGridView.Rendering.ASPxGridViewRenderHelper.AddTemplateToControl(Control destination, ITemplate template, Control templateContainer, TemplateContainerCollection collection, Boolean doDataBinding) +194
DevExpress.Web.ASPxGridView.Rendering.ASPxGridViewRenderHelper.AddDataItemTemplateControl(Int32 visibleIndex, GridViewDataColumn column, Control templateContainer) +211
DevExpress.Web.ASPxGridView.Rendering.GridViewTableDataCell.CreateControlHierarchy() +109
DevExpress.Web.ASPxClasses.Internal.InternalTableCell.CreateChildControls() +24
System.Web.UI.Control.EnsureChildControls() +102
DevExpress.Web.ASPxClasses.Internal.InternalTableCell.DevExpress.Web.ASPxClasses.Internal.IASPxWebControl.EnsureChildControls() +10
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control, Boolean skipContentContainers) +138
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control, Boolean skipContentContainers) +156
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control, Boolean skipContentContainers) +156
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control) +40
DevExpress.Web.ASPxClasses.ASPxWebControlBase.CreateChildControls() +49
System.Web.UI.Control.EnsureChildControls() +102
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControls() +4
DevExpress.Web.ASPxClasses.ASPxWebControlBase.DevExpress.Web.ASPxClasses.Internal.IASPxWebControl.EnsureChildControls() +10
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control, Boolean skipContentContainers) +138
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control, Boolean skipContentContainers) +156
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control, Boolean skipContentContainers) +156
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control, Boolean skipContentContainers) +156
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControlsRecursive(Control control) +40
DevExpress.Web.ASPxClasses.ASPxWebControlBase.CreateChildControls() +49
DevExpress.Web.ASPxClasses.ASPxWebControl.CreateChildControls() +142
System.Web.UI.Control.EnsureChildControls() +102
DevExpress.Web.ASPxClasses.ASPxWebControlBase.EnsureChildControls() +4
DevExpress.Web.ASPxClasses.ASPxWebControlBase.get_Controls() +21
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +24
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Page.LoadAllState() +312
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +747Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Nachdem auf der Lauf im Debugger und „Bei Ausnahmen anhalten“ leider keine neuen Erkenntnisse gebracht hatten, bin ich durch diesen Artikel auf die Lösung gekommen:
Im Init
-Ereignis des GridView-Steuerelements habe ich die Eigenschaft SettingsPager.PageSize
gesetzt. Diese Zuweisung an die Eigenschaft hat die (indirekte) NullReferenceException
ausgelöst.
Nachdem ich die Zuweisung entfernt hatte, lief alles wieder. Seltsam.
Versteh ich nicht.