Always go into misunderstanding on this issue
Misunderstanding 1: always try to get the specific control of each row through FindControl in ASP. Net.
Misunderstanding 2: always try to avoid generating the DataError event of the DataGridview.
After reading many articles, I finally accepted the clone-like relationship between controls in the cells in the Combobox column.
After accepting this reality, if you still have more personalized requirements for the Combobox columns and are unwilling to do too much rewrite work, the performance sacrifice cannot be avoided.
You can do this:
First, add the Combobox drop-down list processing in the appropriate place
Private Sub DataGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles DataGridView1.CellBeginEdit
If e.ColumnIndex = 1 Then
Dim TempDataGridViewComboBoxCell As DataGridViewComboBoxCell = CType(DataGridView1(e.ColumnIndex, e.RowIndex), DataGridViewComboBoxCell)
TempDataGridViewComboBoxCell.Dispose()
TempDataGridViewComboBoxCell.Items.Add(Rnd)
TempDataGridViewComboBoxCell.Items.Add(Rnd)
TempDataGridViewComboBoxCell.Items.Add(Rnd)
TempDataGridViewComboBoxCell.Items.Add(Rnd)
End If
End Sub
The second is to add a DataError event to handle possible errors. The solution to the error is to do nothing.
Private Sub maid (ByVal sender As Object, ByVal e As System. Windows. Forms. DataGridViewDataErrorEventArgs) Handles maid
'Leave it empty.
End Sub