|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DBNull in DataGriddbnull error . How. In the datatable columnchanged event. Private Sub dtGLJnDetail_ColumnChanged(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles dtGLJnDetail.ColumnChanged If IsDBNull(Me.dgDetail(dgDetail.CurrentCell.RowNumber, dgDetail.CurrentCell.ColumnNumber)) = True Then Me.dgDetail(dgDetail.CurrentCell.RowNumber, dgDetail.CurrentCell.ColumnNumber) = "" <--- It can solve BUT.... End If (A) IF e.row("acctcode") = "" then Messagebox.show("Account Code Cannot Be Blank!") <--- It doesn't work . (B) Dim strAcctCode as string strAcctCode = e.Row("acctcode") If strAcctCode.Trim.Length = 0 Then Messagebox.show("Account Code Cannot Be Blank!") <-- It works. Why(A) doesn't work . my datagrid got 10 columns. If I use approach (B) , it seems very stupid. Does anyone got other idea ? Thanks a lot Agnes,
There is a difference between a = "" and a Is DbNull.Value The last references to the object DBNull.Value Cor |
|||||||||||||||||||||||