Question Cannot filter data in dataset wpf application

Govind Sankar

Active member
Joined
May 15, 2020
Messages
42
Programming Experience
Beginner
I have a dataset with column is known as Card_type_1. There 3 types of cards are there. One is SAR41, SAR42 and SAR108. This is a recent change. A week before it was 41,42 and 108, and now I changed it to SAR41, SAR42 and SAR108. Now there is a filter button which checks for each set of cards.
For eg;
DataView view = ds.UNIO.DefaultView;
view.RowFilter = "Card_type_1='42' ";
This used to be the one before when card type was just 42 and at that time it worked perfectly, it showed all the cards in the dataset where Card_type_1 = 42. But then I changed Card_type_1 to SAR42 and the filter button was showing 0 cards which is obvious since the program looks for 42 when in the dataset it is SAR42. So I went to the filter program area and change there also to SAR42 like this.
DataView view = ds.UNIO.DefaultView;
view.RowFilter = "Card_type_1='SAR42' ";
But there also it is not working. It is still showing 0 cards. Have I missed something? Is there anything else to be done. This is a wpf application and there is a button called filter that filters the cards accordingly. Can anyone tell me what am I missing here. Thank You.
 
This may not answer your question directly in terms of what is failing with your filter above, but in my opinion, what you are missing is that most people who abandon WinForms for WPF also abandon using DataSet's and DataTable's and switch over to using some sort of ORM.

Anyway, it sounds like your problem is specific to the use of a DataView filter and not really tied to the use of WPF. In other words the issue would occur regards of WPF or WinForms as the UI framework.
 
This may not answer your question directly in terms of what is failing with your filter above, but in my opinion, what you are missing is that most people who abandon WinForms for WPF also abandon using DataSet's and DataTable's and switch over to using some sort of ORM.

Anyway, it sounds like your problem is specific to the use of a DataView filter and not really tied to the use of WPF. In other words the issue would occur regards of WPF or WinForms as the UI framework.
I dont know what the problem is. The problem is not actually with the code but something happened with that copy. How I do is everytime whenever I make a change, I make a copy of the previous version and then do the change to that. This time I realised some other things were also not working in this new copy like message box, console.writeline etc. So what I did is delete that copy, made another copy from the actual version and did the process again and this time it worked. Now the code is working perfectly fine. Dont know what happened earlier. Thank You.
 
Are you using a generic DataSet or is this a typed DataSet? If it is a typed DataSet, my understanding is that you need to go through the designer again if you change the schema of the database in anyway.
 

Latest posts

Back
Top Bottom