Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Filtering in BindingSource of a generic List

Filtering in BindingSource of a generic List

Scheduled Pinned Locked Moved C#
databasesql-serversysadminhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jaypatel512
    wrote on last edited by
    #1

    I need to have a databinding of List or anything .. I have SQL SErver and a functions which returns List from Database.. Now if I am doing like this: BindingSource src = new BindingSource(); src.DataSource = Book.GetList(); //A Getlist function from Book class returning the list object. datagridview1.DataSource = src; Everything works fine.. But if I need to filter the bindingsource , I know we have a filter property like this. src.Filter = "Author = " + anything.ToString(); But this is not working... But if I am having a DataSource of DataTable having a table of Book . . ie. . if I write.. src.DAtaSource = Book.GetTable(); Everything goes fine .. But on List it doesnt work properly . . Can anyone help me out ???

    M 1 Reply Last reply
    0
    • J jaypatel512

      I need to have a databinding of List or anything .. I have SQL SErver and a functions which returns List from Database.. Now if I am doing like this: BindingSource src = new BindingSource(); src.DataSource = Book.GetList(); //A Getlist function from Book class returning the list object. datagridview1.DataSource = src; Everything works fine.. But if I need to filter the bindingsource , I know we have a filter property like this. src.Filter = "Author = " + anything.ToString(); But this is not working... But if I am having a DataSource of DataTable having a table of Book . . ie. . if I write.. src.DAtaSource = Book.GetTable(); Everything goes fine .. But on List it doesnt work properly . . Can anyone help me out ???

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I'm just getting into the List stuff as well, looks like you need to write your own filtering methods. Look into List.FindAll. I'm still to be convinced a List<> is better than a datatable/view for this stuff. Ah well research, it's what keeps us interested!

      Never underestimate the power of human stupidity RAH

      J 1 Reply Last reply
      0
      • M Mycroft Holmes

        I'm just getting into the List stuff as well, looks like you need to write your own filtering methods. Look into List.FindAll. I'm still to be convinced a List<> is better than a datatable/view for this stuff. Ah well research, it's what keeps us interested!

        Never underestimate the power of human stupidity RAH

        J Offline
        J Offline
        jaypatel512
        wrote on last edited by
        #3

        Yes It's preety fine to work with list. . As it can be handled very easily. And also It can be easily used in 3 tier architecture. Regarding the filtering of list , Actually list can be filtered using LINQ. It can be done something like this; var result = from p in lststudents where p.FirstName = 'Jay' select p; This works fine. But I am more precisely talking about the filtering of Binding source. It works with datatable , but not with List.. Anyway thanx for your concern. .

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups