以下代码在 Asp.net Gridview 控件内的数据第 1 页上效果很好:
If e.CommandName = "Void" Then
'Read the status of the ticket currently
Dim RowIndex As Integer = CInt(e.CommandArgument)
Dim row As GridViewRow = grdTradeTickets.Rows(RowIndex)
Dim lblTransactionID As Label = DirectCast(row.FindControl("lblTransactionID"), Label)
Dim lblTtStatus As Label = DirectCast(row.FindControl("lblTtStatus"), Label)
Dim lblTradeTicketID As Label = DirectCast(row.FindControl("lblTradeTicketID"), Label)
'If already void, show "Already Void" message to user. Else continue "Are you sure you want to void this Trade Ticket?"
If lblTtStatus.Text = "Void" Then
mdlPopupAlready.show()
Else
mdlPopup.Show()
lblTradeTicketIdToVoid.Text = lblTradeTicketID.Text
End If
End If
但是,如果用户在任何后续页面上单击“无效”按钮,则会引发以下错误:
“索引超出范围。必须为非负数且小于集合的大小。参数名称:索引”
它不像索引是空的或什么的。它有一个价值。想法?