J
Jacksm
When I delete a row using datatable.row.delete() it deletes the row
from the datatable instead of just marking it in the datatable so when
I go to to an adapter.update(datatable) i am getting primary key
violations. Any help would be appreciated above is my code for
deleting a row. It has been working but now it is not.
When I post back to the gridview the correct rows are deleted, but it
it deleting them from the datatable as well.
Protected Sub grvMain_RowDeleting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles
grvMain.RowDeleting
Dim dtCart As System.Data.DataTable
Dim c, i, j As Integer
dtCart = Session("Cart")
i = e.RowIndex + 1
For j = i To dtCart.Rows.Count - 1
Dim ae As Integer = dtCart.Rows(j).Item(0)
dtCart.Rows(j).Item(0) = ae - 1
Next
dtCart.Rows(e.RowIndex).Delete()
Session("Cart") = dtCart
grvMain.DataSource = dtCart
grvMain.DataBind()
from the datatable instead of just marking it in the datatable so when
I go to to an adapter.update(datatable) i am getting primary key
violations. Any help would be appreciated above is my code for
deleting a row. It has been working but now it is not.
When I post back to the gridview the correct rows are deleted, but it
it deleting them from the datatable as well.
Protected Sub grvMain_RowDeleting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles
grvMain.RowDeleting
Dim dtCart As System.Data.DataTable
Dim c, i, j As Integer
dtCart = Session("Cart")
i = e.RowIndex + 1
For j = i To dtCart.Rows.Count - 1
Dim ae As Integer = dtCart.Rows(j).Item(0)
dtCart.Rows(j).Item(0) = ae - 1
Next
dtCart.Rows(e.RowIndex).Delete()
Session("Cart") = dtCart
grvMain.DataSource = dtCart
grvMain.DataBind()