某一列改变,就生成一个编号,但这一列不能是 编号列,不然会造成死循环。
If e.DataCol.Name = "日期" Then Dim max As String = e.DataTable.Compute("Max(khbh)", "khbh like '" & Format(Date.Today, "yyyyMMdd") & "*'") If max Is Nothing Then e.DataRow("khbh") = Format(Date.Today, "yyyyMMdd") & "0001" Else Dim num As Integer = max.SubString(8, 4) + 1 e.DataRow("khbh") = Format(Date.Today, "yyyyMMdd") & Format(num, "0000") End If End If
|