vb.netdatagriddevexpress

Update Cells in a Grid - DevExpress Grid Control


How do I loop through each row in this grid and update the price when it finds the "Department" 78102? I found some links when googled but none showed what I was looking for.

Googled and tried several links

ItemNo  Department  Description StoreNumber Price
1       18331       Home        71832       75.5
2       29653       Lawn        43108       299.95
*3      78102       Plumbing    80001*  
4       44001       Electrical  38913       108.99
5       51836       Wood        41009       39.99

Solution

  • To loop over datagridview is like you see below

        For Each row As DataGridViewRow In DataGridView1.Rows
    
            If row.Cells("Department").Value = 78102  Then
                row.Cells("Department").Value = 10
            End If
        Next
    

    But your datasource of the dtagridview like a DataTable, will also be updated, but you still need a UPDATECOMMAND, to send the data to your database or whatever your source is.