Link to home
Start Free TrialLog in
Avatar of kdeutsch
kdeutschFlag for United States of America

asked on

Delete link in datagrid not working

I am trying to add a delete link button to a daragrid in asp.net 1.1.  I have the link button in and code from MSDN that looks like it gets intot he correct position of datagrid when I do a response.write index it looks at the correct rows.  But my delete functionality does not work.  How can i delete that row from the table where the StrRecordNumber is equal to itself.

THIS IS MY LINK BUTTON IN DATAGRID

<asp:TemplateColumn HeaderText="Delete">
<ItemTemplate>
<asp:linkbutton id="lnkDelete" runat="server" text="Delete" commandname="Delete"></asp:linkbutton>
</ItemTemplate>
</asp:TemplateColumn>

THIS IS MY CODE BEHIND THAT GETS AT THE DATAGRID ROW.
Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)Handles myDataGrid.DeleteCommand

 Dim index As Integer
 index = e.Item.ItemIndex

        insertUpdateDelete("delete table1 where strRecordNumber = '" & ID & "'")
Insertupdate delete calls out my connectionstring from my common.vb file.
        myDataGrid.DataBind()

    End Sub
Avatar of prairiedog
prairiedog
Flag of United States of America image

Is the record deleted in database? Or just the DataGrid does not refresh to reflect the deletion?
Avatar of kdeutsch

ASKER

It is not deleted in the database, I cannot figure out how to match the index number to the strRecordNumber so it deletes the records.
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial