Link to home
Start Free TrialLog in
Avatar of Lensulu
Lensulu

asked on

Dealing with null value cells in a datagridview

I have a datagridview with various columns - where one column has some data on a some rows - with most of the rows having no data ( null info).I want to read row by row skipping any row where the data is null.In VB6 I wrote if column = "" then -skip to next column. This does not work in VB8. Can anyone help please.
I have tried code like
"If Convert.ToInt32(Me.TransactDataGridView.Rows(i).Cells(1).Value.ToString()) = 0 Then"
-this does not work.
Avatar of Ashok
Ashok
Flag of United States of America image

Try

If (Me.TransactDataGridView.Rows(i).Cells(1).IsDbNull) Then

Ashok
Should this be also in Visual Basic.NET ZONE ?

Ashok
Avatar of Lensulu
Lensulu

ASKER

My telesense does not pick up isdbnull. Am i missing a space import.
Avatar of Lensulu

ASKER

My telesense does not pick up isdbnull. Am i missing a space import.I only need in vb net.
       Dim ob As Object = Me.TransactDataGridView.Rows(1).Cells(1)
        If (Convert.IsDBNull(ob)) Then

        End If

HTH
Ashok
      Dim ob As Object = Me.TransactDataGridView.Rows(i).Cells(1)
       If (Convert.IsDBNull(ob)) Then

       End If

HTH
Ashok
Could you add ZONE "Visual Basic.NET" to this question?

Ashok
Avatar of Lensulu

ASKER

 Dim ob As Object = Me.TransactDataGridView.Rows(i).Cells(1)
            rbPayandDEp.Checked = True
            'here code for both

            counter = 0
            Do While i < rowcount - 1
                ' If (Me.TransactDataGridView{ColumnIndex=1,Rowindex=i} = "x" Then
                ' MsgBox(Me.TransactDataGridView.Rows(i).Cells(1).ToString)
                If (Convert.IsDBNull(ob)) Or (Me.TransactDataGridView.Rows(i).Cells(1).Value.ToString) = " " Then
                    Me.TransactDataGridView.Rows(i).Cells(1).Value = prefix + ((startnumber + counter).ToString)
                    'increment counter when found
                    counter = counter + 1
                 
                End If
             
                i = i + 1



            Loop
The above code does not code the blanks or null items.It just runs through without an error.

You asked me to include ZONE vbNet - how do i do that at this point. It is a Zone VB net problem.

Thansk
If IsDBNull(Me.TransactDataGridView.Rows(i).Cells(1)) Then


End If
ASKER CERTIFIED SOLUTION
Avatar of Ashok
Ashok
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lensulu

ASKER

Thanks - I'm learning.first steps taken.

Avatar of Lensulu

ASKER

Finally solved problem - thanks very much
Ashkok111.