Select Case e.DataCol.Name Case "出生日期" If e.DataRow.IsNull("出生日期") Then '身份证号码是否为空 e.DataRow("年龄") = Nothing '如果为空,则清除年龄 Else Dim d As Date = e.NewValue Dim y As Integer = d.year If format(d, "MMdd") <= Format(Date.Today, "MMdd") Then e.DataRow("年龄") = Date.Today.Year - y Else e.DataRow("年龄") = Date.Today.Year - y -1 End If End If End Select