I need to retrieve the data contained inside a WebDataGrid. What is the best way to do it?
At first I thought I could do something like this below (ADO.NET DataTable style) :
I know I can get the value using the column index rec.Items[0].Value . Is there a way I can use the column Key name?
Thanks
Daniel
Since I was only concerned about reading the data, my solution was to write a function to convert the DataGridRow to a HashTable. The function returns a hashtable with the keys set to the columns' Key values. If you use the same string in your column DataFieldName and Key properties, you will get a hashtable very similar to as the HashTable returned by RowUpdatingEventArgs.Values
Private Function GridRecordToHashTable(ByVal gridRecord As GridRecord) As Hashtable Dim hashTable As New Hashtable() Dim i As Integer = 0 ' for each didn't work here, it would exit loop after first iteration For i = 0 To gridRecord.Items.Count - 1 Dim key As String = gridRecord.Items(i).Column.Key Dim value As String = gridRecord.Items(i).Text hashTable(key) = value Next Return hashTable End Function