Hi Liste,

ich habe in meiner Session eine DataTable, aus der ich gerne einen eintrag löschen würde. das wollte ich mit folgender funktion machen:
Sub DeleteArtikel(ByVal id As Integer)

Dim objDataTable As DataTable = CType(Session("warenkorb"), DataTable)

Dim i As Integer

For i = 0 To objDataTable.Rows.Count - 1

If CInt(objDataTable.Rows(i)("id")) = id Then

objDataTable.Rows.RemoveAt(i)

End If

Next

objDataTable.AcceptChanges()

If objDataTable.Rows.Count = 0 Then

Response.Redirect("warenkorb.aspx")

Else

Datenlesen()

End If

End Sub


jedoch bekomme ich danach immer folgende exception:

There is no row at position 2.
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:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:


[IndexOutOfRangeException: There is no row at position 2.]
  System.Data.DataRowCollection.get_Item(Int32 index) +63
  Vinerie.Warenkorb.DeleteArtikel(Int32 id) +102
Vinerie.Warenkorb.ibtnDelete_Click(Object sender, ImageClickEventArgs e) +40
  System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +109
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +69 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
  System.Web.UI.Page.ProcessRequestMain() +1277



-----------------------------------------------
SitePoint GbR
Thomas Beckert
Vorstadtstr.57
66117 Saarbrücken

Tel.: +49 681 / 9 47 26 27
Fax.: +49 681 / 9 47 26 28

www.sitepoint.de
----------------------------------------------

_______________________________________________
Asp.net Mailingliste, Postings senden an:
[email protected]
An-/Abmeldung und Suchfunktion unter:
http://www.glengamoi.com/mailman/listinfo/asp.net

Antwort per Email an