Dim ls1() As String={"单位","年级","部别"}
Dim dr As DataRow
Dim ls As New List(of String)
ls.AddRange(ls1)
Dim n As String = e.DataCol.Name
If ls.Contains(e.DataCol.Name) Then
If e.NewValue Is Nothing Then '如果新值是空白
e.DataRow("目标1") = Nothing '那么清空此行目标1列的内容
Else
'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
ls.Remove(n)
dr = DataTables("校名设置").Find("[" & n & "] = '" & e.NewValue & "' and [" & ls(0) & "]='" & e.DataRow(ls(0)) & "' And [" & ls(1) & "]='" & e.DataRow(ls(1)) & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
e.DataRow("目标1") = dr("目标1")
End If
End If
End If