Mehyar Posted December 1, 2003 Posted December 1, 2003 Ok guys, its been 3 days I have been trying to solve this and i am giving up. I pulled every hair out of my head, so I am practically bald now. I have a DataTable (part of a dataset that is binded to the database) Each time the user selects an option and clicks on a button I open a new form with a datagrid binded to that datatable according to the option selected. What I mean is Each time I open the form I set the RowFilter property of the DefaultView of that table to the following. Dt.DefaultView.RowFilter = "Basis = 'A' or Basis is Null" How ever if I add a new record for A and I havent called AcceptChanges and I select Option B, the record for A appears, as if the RowFilter is not working. First I thought it could be a RowState problem but I tried the RowStateFilter for all the values the same damn thing happens. If I call AcceptChanges it works fine. But my problem is that it is impossible to call AcceptChanges because i Have a windows forms that updates to a remote database through a web service, so I need to send the DataSet with its changes to the web service to know what to update. I started to feel this is a bug, I mean why should I call Accept Changes for this rowfilter to work ?? Any ideas guys...... Quote Dream as if you'll live forever, live as if you'll die today
*Experts* Nerseus Posted December 1, 2003 *Experts* Posted December 1, 2003 First, it's probably better to use a new DataView object rather than change the DefaultView. You don't have to, but I'm guessing the main form and the popup are bound to the same DataTable and changing the filter in one form might make the other form's bound controls update when it sees the filter changing. But, that's not a solution to your problem, just an observation. Have you tried specifying a DataViewRowState? If you create a new DataView you can tell it what rows you want: DataView dv = new DataView(Dt, "Basis = 'A' or Basis is Null", String.Empty, DataViewRowState.CurrentRows) -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Mehyar Posted December 2, 2003 Author Posted December 2, 2003 I have tried all the possibilities of the datarowview states and it didnot work. I also tried creating another dataview and the same problem happened. I finally solved it, well not solved it because I do not consider this a solution just a weird behaviour on .NET's part. This is how i Solved it... I noticed that it only happens the first time i open the pop up, the second time it works ! Moreover, I noticed that once i click on a row in the datagrid that should not be there (i.e) doesnot belong to the row filter then i click on another cell. Suddenly the row filter works and everything goes fine. I could not really find a reasonable explanation for this behaviour. But what I did is that on Paint of the datagrid I changed the current cell so it worked !!! Thats enough for me, but it is weird .... Quote Dream as if you'll live forever, live as if you'll die today
szich Posted December 31, 2003 Posted December 31, 2003 This may help... http://www.syncfusion.com/FAQ/WinForms/FAQ_c43c.asp#q907q Quote
yan19454 Posted January 8, 2004 Posted January 8, 2004 I tried to do similiar thing for the data grid and looked for solution month. I did not know what to do. My datagrid present the data (name and id and location ). It sort by name. If I added one new record, it put in the end of the datagrid. I want them to put in the proper order. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.