in

CodeSmith Community

Your Code. Your Way. Faster!

delete failed?

Last post 04-11-2008 3:18 AM by lionelluo. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 04-11-2008 3:18 AM

    delete failed?

    Hi, I try the follow code:

    1<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server"
    2       DataSourceID="CustomersDataSource1"
    3       DataKeyNames="CustomerID"  
    4       PageSize="10" AllowPaging="true" AllowSorting="true">
    5   <Columns>
    6      <asp:CommandField ShowEditButton="True" />
    7      <asp:BoundField DataField="CustomerID" HeaderText="Cust #" SortExpression="CustomerID" />
    8      <asp:BoundField DataField="CompanyName"
    9            HeaderText="Company" SortExpression="CompanyName" />
    10      <asp:BoundField DataField="ContactTitle" HeaderText="Title" SortExpression="ContactTitle" />
    11      <asp:BoundField DataField="ContactName" HeaderText="Name"
    12            SortExpression="ContactName" />
    13      <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
    14      <asp:BoundField DataField="Region" HeaderText="Region" SortExpression="Region" />
    15      <asp:BoundField DataField="PostalCode" HeaderText="Postal Code"
    16            SortExpression="PostalCode" />
    17      <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
    18      <asp:CommandField ShowDeleteButton="true" />
    19   </Columns>
    20</asp:GridView>
    21<code>
    22
    23Next, add the CustomersDataSource control to your page: 
    24This is the tough part, so strap it in!!!
    25
    26<code lang="XML" linenumbers="false">
    27<data:CustomersDataSource ID="CustomersDataSource1"
    28   runat="server"
    29   SelectMethod="GetPaged"
    30   EnablePaging="true"
    31   EnableSorting="true"/>

     

    and when click delete, got error:

    Server Error in '/Northwind.Website' Application.

    The entity object cannot be null.

    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: The entity object cannot be null.

    Source Error:

    Line 1949:				
    Line 1950:				// default exception
    Line 1951:				throw new NullReferenceException("The entity object cannot be null.");
    Line 1952:			}
    Line 1953:		}


    Source File: C:\NetTiers\Northwind\Northwind.Web\Data\BaseDataSource.cs    Line: 1951

    How to fix it? Please help.

     

    • Post Points: 5
Page 1 of 1 (1 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems