How to use Dataview to filter data from a datatable

In some situations,we need the extract data from datatable.Dataview can be used to filter the data from datatable.

This code shows how to use DataView to filter data from datatable.

Dim objDT As New DataTable
Dim objDV As DataView
Dim strQuery As String

'Query for filling data in datatable.
strQuery = "Select * from OITM"
'In GetData() function,query is fired and data is
'saved in objDT.
objDT = GetData(strQuery)
If objDT.Rows.Count > 0 Then
'The dataview objDV is filtered over the column
'code.All the records whose Code is BBAG are
'extracted from the datatable objDT and saved in
'dataview objDV.
objDV=New DataView(objDT,"Code='BBAG'","Code",DataViewRowState.CurrentRows)
If objDV.Count > 0 Then
'The value from 1st row and 1st column is displayed
End If
End If


Author: Narendra Dashpute04 Mar 2010 Member Level: Bronze   Points : 1

Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code will help lots of guys

Author: Ahmad Nauman27 Apr 2010 Member Level: Bronze   Points : 2

This one seems to me different type of who dont know about it before may get useful information from this post...well i wanna say that The way how you tried to explain some posts at here seems to me different...there are certainly different posts at here,but i didnt find any post related to projects like 642-515...if someone have information about it,do tell me!Well any updates related to this post?if yes than do tell me!actually i came here while surfing net to get data related to projects of 642-611 , testking ccna and find this post different one...Is there anyone having information about 642-746?any updates?if yes than do tell me!

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: