11 April 2013

Delete is not working (GridView + ObjectDataSource)

At 6:00 PM, one student trainee asked me why the delete button didn't work after he bound the ObjectDataSource and the GridView.

When I checked his code, I found another obvious mistake that he forgot this "simple thing" to make the delete method worked.

Here's my workaround:

1. I added the delete parameter inside the ObjectDataSource. Example:

<DeleteParameters>
                <asp:Parameter Name="EmployeeId" Type="Int32" />

</DeleteParameters>

2. Then, I added a DataKeyNames inside the GridView. Example:

DataKeyNames="EmployeeId"


That's it. It worked.

No comments:

Post a Comment