Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
160
Retrieve Data from WebDataGrid.Rows
posted

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) :

foreach (Infragistics.Web.UI.GridControls.GridRecord rec in WebDataGrid1.Rows)
{
     rec[
"MyColumn"];  // Do something with the value here
}

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

Parents
No Data
Reply
  • 385
    posted

    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

     

Children
No Data