Dim dr As DataRow = e.DataRow Dim dt As DataTable = DataTables("学生成绩") If e.DataCol.Name = "班级" Then dr("男生人数") = dt.Compute("count([性别])", "[性别] = '男' and [班级] = '" & dr("班级") & "'" ) dr("女生人数") = dt.Compute("count([性别])", "[性别] = '女' and [班级] = '" & dr("班级") & "'" ) End If