This is *almost* working... for some reason, when I press the delete link (in a ButtonColumn, commandname="Delete", I get:
Line 233: Dim dscol1 = ds.Tables("Details".Rows(i).Item("ID"
but if i hit reload and repost, it removes the correct record... what the heck is going on??? i've rebooted, cleared cache, all that jazz... by the way, there were 3 rows when i got that, I printed it to a textbox to make sure it had all the rows...
here is the delete code.
any help is greatly appreciated...
Code:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: There is no row at position 2.
Source Error:
Line 231: Dim i As Integer
Line 232: For i = 0 To ds.Tables("Details").Rows.Count() - 1
Code:
Line 234:
Line 235: If dscol1 = SelectedID Then
but if i hit reload and repost, it removes the correct record... what the heck is going on??? i've rebooted, cleared cache, all that jazz... by the way, there were 3 rows when i got that, I printed it to a textbox to make sure it had all the rows...
here is the delete code.
Code:
Sub MeetingDetails_DeleteCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim dr As DataRow
Dim SelectedID As String = MeetingDetails.DataKeys(e.Item.ItemIndex)
Dim ds As New DataSet()
ds = Session("MeetingDetailsDS")
Dim dTable As New DataTable()
dTable = ds.Tables("Details")
txtFoodReqs.Text = SelectedID
Session("MeetingDetailsDS") = ds
Dim i As Integer
For i = 0 To ds.Tables("Details").Rows.Count() - 1
Dim dscol1 = ds.Tables("Details").Rows(i).Item("ID")
If dscol1 = SelectedID Then
ds.Tables("Details").Rows(i).Delete()
End If
Next
ds.Tables("Details").AcceptChanges()
Dim agendaDV As DataView = New DataView(ds.Tables("Details"), "", "Date,Start,End ASC", DataViewRowState.CurrentRows)
Session("MeetingDetailsDS") = ds
MeetingDetails.DataSource = agendaDV
MeetingDetails.DataBind()
End Sub
any help is greatly appreciated...