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>2223Next, add the CustomersDataSource control to your page: 24This is the tough part, so strap it in!!!2526<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:
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.