Visit this link,
http://www.aspnet.4guysfromrolla.com/articles/080702-1.2.aspx
look for the other parts.It is a multipart document(9 parts) and in one of the part..he has given the correct syntax to delete.
: : Hey everyone,
: :
: : I am having a problem with a datagrid i set up. I can update the source just fine, but when i go to delete records, i get problems. As long as the primary Keys are in order and do not skip a number, it works fine, but when i add a record, delete it, then add another record, I can't delete the second record. The delete link shows as though it's been clicked before too. I don't know what's causing this problem. Here is the source i am using. Can anyone help??
: :
: : sub asGrid_Delete(obj as object, e as DataGridCommandEventArgs)
: : dim strSQL as string = "DELETE FROM tbAvailableSituations _
: : WHERE asID = " & e.Item.ItemIndex + 1
: : ExecuteStatement(strSQL)
: : UpdateDate()
: : FillasDataGrid()
: : end sub
: :
: : <asp:datagrid id="asGrid" runat="server" BorderColor="black" GridLines="Both" CellPadding="4" CellSpacing="0" width="450" ShowFooter="true" HeaderStyle-BackColor="#cccc99" FooterStyle-BackColor="#cccc99" ItemStyle-BackColor="#cccccc" AlternatingItemStyle-BackColor="#ffffff" AutoGenerateColumns="false" OnDeleteCommand="asGrid_Delete" onEditCommand="asGrid_Edit" onCancelCommand="asGrid_Cancel" OnUpdateCommand="asGrid_update" OnPageIndexChanged="asGrid_PageIndexChanged">
: : <columns>
: : <asp:templatecolumn headerText="ID">
: : <itemtemplate>
: : <asp:label id="ID" runat="server" text='<%# _
: : Container.Dataitem("asID") %>' />
: : </itemtemplate>
: : </asp:templatecolumn>
: :
: : <asp:boundcolumn headertext="Situation" dataField="asSituation">
: : </asp:boundcolumn>
: :
: : <asp:editcommandcolumn editText="edit" CancelText="Cancel"
: : UpdateText="Update" ItemStyle-Wrap="false"
: : HeaderText="Edit" />
: : <asp:buttoncolumn headertext=" " Text="Delete"
: : commandname="delete" />
: : </columns>
: : </asp:datagrid>
: :
: :
:
: c v Biju
:
:
c v Biju