dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersA'zlina
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » Code Snippets » Visual Studio

How to get the Filtered data from the DevExpress Datagrid ?


Posted Date:     Category: Visual Studio    
Author: Member Level: Silver    Points: 10


Here I would like to share with you a code snippet to get only the filtered data from the DevExpress Datagrid. We know that there is an option in GridControl to set the AutoFilterRow as True so that we can filter out the contents easily. But when we are exporting the data, the whole contents will be exported, not just the filtered content. To avoid this, write the following code.



 


Learn how to get the Filtered data from the DevExpress Datagrid?


Here, we are reading the data from database in the function GetDataFromDatabase() and storing it in the dataset, ds. Then we are displaying it on to the datagrid. (This code may be written in the Read button.)



Dim ds As New DataSet
Dim dv As DataView
ds = GetDataFromDatabase()
Dim dvManager As New DataViewManager(ds)
dv = dvManager.CreateDataView(ds.Tables(0))
GridControl1.DataSource = dv



We are copying the data in datagrid on to another table, dtRecords. (whole data read from the database will be there.)

If ActiveFilterCriteria is present, then the filtered contents is copied to dtRecords.



Dim dtRecords As DataTable = dv.ToTable

If Not (IsNothing(GridView1.ActiveFilterCriteria)) Then
Dim filteredDataView As New DataView(dtRecords)
filteredDataView.RowFilter = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(GridView1.ActiveFilterCriteria)
dtRecords = filteredDataView.ToTable
End If




We could set the AutoFilterRow as True by clicking 'Run Designer' in GridControl1 -> 'Feature Browser' on the left hand side -> 'Filtering' -> In its Properties 'OptionsView' -> set 'ShowAutoFilterRow' as True





Did you like this resource? Share it with your friends and show your love!


Responses to "How to get the Filtered data from the DevExpress Datagrid ?"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • 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:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: How to show the progress in DevExpress Progress bar ?
    Return to Resources
    Post New Resource
    Category: Visual Studio


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    VB.NET  .  DevExpress  .  Get Filtered Contents From Datagrid  .  AutoFilterRow  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.