DateRowAdding事件,代码
Dim bh As String = Format(Date.Today, "yyyyMMdd")Dim max As String = e.DataTable.Compute("max(编号)", "编号 like '" & bh & "%'")Dim idx As Integer = 1If max > "" Then idx = Cint(max.SubString(bh.Length)) + 1Else idx = 1End If
e.DataRow("编号") = bh & format(idx, "0000")