The DataView

 

 

 

            Dim dv As DataView

            dv = objDs.Tables("Can").DefaultView()

            'You can sort by any field....

            dv.Sort = "ssn"

            '... Or you can filter the view down to 1 field...

            dv.RowFilter = "ssn = '-00000014'"

 

            DataGrid1.DataSource = dv

            DataGrid1.DataBind()

 

            'This will return just the amount of rows in the DataView...

            txtCount.Text = objDs.Tables("Can").DefaultView.Count

 

            'This will return all the rows in the table...

            txtTotal.Text = objDs.Tables("Can").Rows.Count

 

 

 

 

How To Reference A Field In A DataView…

 

        Dim dv As DataView = objDs.Tables("Can").DefaultView

        dv.RowFilter = "Lname = 'SisCo'"

        MsgBox(dv(0).Item("LName"))

 

 

 

'How to loop through records in a DataView...

 

        dv = objDs.Tables("Check").DefaultView

        dv.RowFilter = "SeminarLocation='Willingboro'"

 

        Dim J As Integer

        For J = 0 To dv.Count - 1

            'Do Something...

        Next J