Home All Groups Group Topic Archive Search About
Author
12 Apr 2005 4:06 AM
Agnes
in the datagrid, if the user use backspace to delete it . Then I will got an
dbnull 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

Author
12 Apr 2005 8:32 AM
Cor Ligthert
Agnes,

There is a difference between
a = ""
and
a Is DbNull.Value

The last references to the object DBNull.Value

Cor