Public Sub RememberOldValues(ByVal dic As Dictionary(Of String, Boolean), ByVal gdv As Grid)
For i As Integer = 0 To gdv.Rows.Count - 1
Dim currentValue As String = gdv.Rows(i).DataKeys(0)
Dim currentCbx As New System.Web.UI.WebControls.CheckBox
currentCbx = gdv.Rows(i).FindControl("CheckBox1")
If currentCbx.Checked AndAlso dic(currentValue) = False Then
dic(currentValue) = True
ElseIf Not currentCbx.Checked AndAlso dic(currentValue) = True Then
dic(currentValue) = False
End If
Next
End Sub 调试的时候dic的值达到要求。
Public Sub RePopulateValues(ByVal dic As Dictionary(Of String, Boolean), ByVal gdv As Grid)
For Each row As GridRow In gdv.Rows
Dim currentValue As String = row.DataKeys(0)
Dim currentCbx As System.Web.UI.WebControls.CheckBox = TryCast(row.FindControl("CheckBox1"), System.Web.UI.WebControls.CheckBox)
If dic(currentValue) = True Then
currentCbx.Checked = True
Else
currentCbx.Checked = False
End If
Next end sub