2008年5月12日 星期一

ExtractRowValues

Function ExtractRowValues(ByVal Columns As DataControlFieldCollection, ByVal Row As GridViewRow) As OrderedDictionary
        Dim oFieldValues As OrderedDictionary
        Dim oColumn As DataControlField
        Dim oDictionary As OrderedDictionary
        Dim oEntry As DictionaryEntry
        Dim N1 As Integer

        oFieldValues = New OrderedDictionary(Columns.Count)
        oDictionary = New OrderedDictionary()

        For N1 = 0 To Columns.Count - 1
            oColumn = Columns.Item(N1)
            If oColumn.Visible Then
                oDictionary.Clear()
                oColumn.ExtractValuesFromCell(oDictionary, TryCast(Row.Cells.Item(N1), DataControlFieldCell), Row.RowState, True)
                For Each oEntry In oDictionary
                    oFieldValues.Item(oEntry.Key) = oEntry.Value
                Next
            End If
        Next

        Return oFieldValues
    End Function
Source