ASP.NET Gridview Delete Command Event

818 views Asked by At

Hi I have created a buttonfield in my Gridview with the CommandName sent to Delete. I have also Set the RowDeleting event on my GridView to a method. It doesnt run this method though. Giving me the error " Deleting is not supported by data source 'Cars' unless DeleteCommand is specified. "

My question is how do I get a button to launch an event similar to the GridView1_SelectedIndexChanged with the Select command. Thanks

2

There are 2 answers

0
Neil Hibbert On

Have you declared your DataSource like this?

<asp:SqlDataSource ID="SqlDataSource1" runat="server" DeleteCommand="YourDeleteCommand"> <DeleteParameters /> </asp:SqlDataSource>

This will let the GridView know how to perform the delete operation...

0
user673906 On

The problem was I didn't create the row deleted event as well as the row delete event.