表名一定要对应有关联。用下面的代码
If e.DataCol.Name Like "*成绩" = False Then
Dim pdc As new List(Of String)
Dim tdc As new List(Of String)
For Each dc As DataCol In e.DataTable.DataCols
If dc.Name Like "*成绩" Then
pdc.Add(dc.Name)
Else
tdc.Add(dc.Name)
End If
Next
For Each p As String In pdc
Dim sum As Double = 0
For Each t As String In tdc
Dim fdr As DataRow = DataTables("表A").Find("项目 = '" & t & "'")
If fdr IsNot Nothing Then
sum += e.DataRow(t) * fdr("分值_" & p.Replace("成绩", ""))
End If
Next
e.DataRow(p) = sum
Next
End If