none
filtering on a Bindinglist RRS feed

  • Question

  • Hello !

    I'm using vb.net 2017 and entity Framework 6

    I have a Students Table , also I have a Bindingosurce that is configured in design,  and a datagridview bound to this bindingsource.

    I want to first load all students , and after work with local data to fill the bindingsource with the data that I needs :

    I have this code :

    Context.Myobjs1.Students.Load()
    Mybindingsource1.Datasource=Context.obj1s.Local.TobindingList

    If I use this code everything works ok , I can display data on gridview , I can add , delete or modify data on gridview and save them.

    But the problems is that depending on user choice , I want to filter data on bindingsource , so I don't want all the local data that is used on my second line of code ,but for example I want all studnets that have nr>1.

    But if I use :

    Mybindingsource1.Datasource=Context.obj1s.Local.TobindingList.Where(Function(t2) t2.nr>1).Tolist

    The data is displayed correctly in datagridview , but when I add or delete something , the changes are not saved .

    If I try to use :

    Mybindingsource1.Datasource=Context.obj1s.Local.Where(Function(t2) t2.nr>1).TobindingList

    There's no tobindingList in this case.

    I know that I can filter the data when loading from database , but this is not the case because I want to load all data from database , and after I want to work with local data.

    So what can I do ?

    Thank you !


    Monday, December 10, 2018 2:32 PM

All replies