我的问题,看看谁能解决?谢谢。
如图购物车,当按删除键时,一次删除了2记录,是什么原因?
代码如下:
GridView1_RowDeleting事件代码:
Dim order As orderinfo = CType(Session("order"), orderinfo)
order.orderItemList.RemoveAt(e.RowIndex)
If (order.orderItemList.Count = 0) Then
order = Nothing
Else
Dim row As GridViewRow = GridView1.Rows(e.RowIndex)
Dim num As Label = CType(row.FindControl("booksum"), Label)
Dim n As Integer = Integer.Parse(num.Text)
order.TotalNum = (order.TotalNum - n)
Dim price As Label = CType(row.FindControl("bookprice"), Label)
Dim p As Decimal = Decimal.Parse(price.Text)
If (order.sumPrice <> 0) Then
order.sumPrice = (order.sumPrice - p)
Else
Panel1.Visible = False
Label5.Visible = True
End If
End If
'Try
If Not (order Is Nothing) Then
Session("order") = order
End If
showShop()
End Sub
Private Sub showShop()
If Not (Session("order") Is Nothing) Then
Panel1.Visible = True
Label5.Visible = False
Dim order As orderinfo = CType(Session("order"), orderinfo)
GridView1.DataSource = order.orderItemList
GridView1.DataBind()
Label2.Text = order.TotalNum.ToString()
Label4.Text = order.sumPrice.ToString()
Else
Panel1.Visible = False
Label5.Visible = True
End If
End Sub
当按gridview控件中的删除按钮时,一次删除了2条记录,如何解决?谢谢。