更新datagredvew vb.net中每行中coloumn 2中的多个单元格

时间:2017-05-26 07:51:53

标签: vb.net

大家好,我需要帮助。 我有datagridview我想在我点击更新按钮时更新每行中coloumn 2的单元格..

For i As Integer = 0 To dgvTestsRes.Rows.Count
    d.EditData(String.Format("Update sampleResult set samTestResult='{0}' where samResID={1}", dgvTestsRes.Rows(i).Cells(2).Value.ToString(), dgvTestsRes(8, dgvTestsRes.SelectedRows(0).Index).Value.ToString()))
Next

enter image description here

1 个答案:

答案 0 :(得分:0)

试试这个:

Try

    For Each Line As DataGridViewRow In dgvTestRes.Rows

         Line.Cells(1).Value = <YourValue>   <- The column starts from 0, so, 1 = column 2

    Next

Catch

End Try