in

CodeSmith Community

Your Code. Your Way. Faster!

The entity object cannot be null.

Last post 05-08-2008 9:15 AM by blake05. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-22-2008 2:24 PM

    • rithomas
    • Not Ranked
    • Joined on 04-13-2007
    • Posts 2
    • Points 70

    The entity object cannot be null.

    When I attempt to save a record from the entitygridview, I get this error:

    [NullReferenceException: The entity object cannot be null.]
    IGD.Web.Data.BaseDataSourceView`2.ValidateEntity(Entity entity, IDictionary keys) in C:\Projects\xxx\IGD.Web\Data\BaseDataSource.cs:1940
    IGD.Web.Data.BaseDataSourceView`2.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) in C:\Projects\xxx\IGD.Web\Data\BaseDataSource.cs:1558
    System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
    System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1215
    System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +837
    System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
    System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
    System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
    System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132
    System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

     

    Here is my code:

        <data:EntityGridView DataKeyNames="ManufacturerID" ID="gridManufacturer" runat="server" DataSourceID="dataManufacturer" AllowExportToExcel="True" AllowMultiColumnSorting="False" AllowPaging="True" AutoGenerateColumns="False" DefaultSortColumnName="ManufacturerId" DefaultSortDirection="Ascending" ExportToExcelText="Excel" PageSelectorPageSizeInterval="10">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="ManufacturerId" HeaderText="ManufacturerId" ReadOnly SortExpression="ManufacturerId" />
                <asp:BoundField DataField="ManufacturerName" HeaderText="ManufacturerName" SortExpression="ManufacturerName" />
                <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
            </Columns>
        </data:EntityGridView>

        <data:ManufacturerDataSource ID="dataManufacturer" SelectMethod="GetPaged" runat="server" EnablePaging="True">
            <DeepLoadProperties Method="IncludeChildren" Recursive="False">
            </DeepLoadProperties>
        </data:ManufacturerDataSource>

     

    Am I missing something?  The Auto-generated admin screen doesn't work right, either.  No matter what record you edit, it always updates where ManufacturerID = 1. 

    • Post Points: 35
  • 05-08-2008 9:15 AM In reply to

    • blake05
    • Top 50 Contributor
    • Joined on 04-03-2008
    • Wisconsin
    • Posts 74
    • Points 1,205

    Re: The entity object cannot be null.

    Hello,

    Could you email me your database schema and I will take a look at this.

    Thanks

    -Blake

    Blake Niemyjski
    CodeSmith Tools, LLC
    Support Specialist
    • Post Points: 5
Page 1 of 1 (2 items)
Copyright © 2007 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems