checked rows in grid for export in VB

1 reply. Last post: March 31, 2013 10:02 PM by Bernard Xiang
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Jarl HedinMember

I tried this code and it,s not working. I took  your C# exampel and converted it  to VB

what's wrong?  I get this error


Best regards Jarl


Undantagsinformation: System.NullReferenceException: Objektreferensen har inte angetts till en instans av ett objekt.

Källfel:

Rad 25:                 ' if current row is equal to one of the rows in the checked rows
Rad 26:                 ' then break
Rad 27:                 If e.Table.Rows(i).KeyValue.ToString() = keyValue Then
Rad 28:                     IsMatch = True
Rad 29:                     Exit For


        Dim totalRows As Integer = WebGrid1.RootTable.Rows.Count

        For i As Integer = 0 To totalRows - 1

            ' get the number of checked rows

            Dim checkedRowsCount As Integer = WebGrid1.RootTable.GetCheckedRows().Count

            ' a flag that shows whether row is match to one of the rows in the checked rows

            Dim IsMatch As Boolean = False

            For Each keyValue As String In WebGrid1.RootTable.GetCheckedRows()

                ' if current row is equal to one of the rows in the checked rows

                ' then break

                If e.Table.Rows(i).KeyValue.ToString() = keyValue Then

                    IsMatch = True

                    Exit For

                End If

            Next

            ' if current row is equal to one of the rows in the checked rows

            ' then passes to the next iteration

            ' else remove current row

            If IsMatch Then

                Continue For

            Else

                e.Table.Rows.RemoveAt(i)

                i -= 1

                totalRows -= 1

            End If

        Next

        ' set the "IsRowChecker" to be not visible during export

        e.Table.Columns.GetNamedItem("IsRowChecker").Visible = False

    End Sub

 

 
Jarl Hedin
All times are GMT -5. The time now is 1:44 AM.
Previous Next