Updating ListView items bound to SQL table

    General discussion

  • Hello,

    I have a listview control who's columns are bound to an SQL table through a LINQ to SQL class.  When the program is run, the table populates in the listview correctly the way I want it to, but I have a timer that for every 1 second that passes, refreshes the table ... (side question - is there a more elegant way to reflect changes to the table than just query the table every second??) ... and should reflect any new changes to the table, however that doesn't happen.  I manually go into the table and remove a row and that row is not reflected in my WPF listview.  I am populating my listview using the listview.ItemsSource = _myDB.tblInspectionStatus (where the tblInspectionStatus is a table in my database).  The specific GridViewColumns in my listview have dataTemplates in them that house TextBlocks that are bound to the specific columns in my database table.

    Essentially, I guess I have two questions:  1) How do I reflect the changes to my database table on my UI and 2) is there an easier way to update the UI rather than using a timer to trigger an event (I read a little something about the INotifyPropertyChanged interface, so I don't know if that has anything to do with it since the specific property isn't being changed, but rather the whole table is)

    • Changed type Marco Zhou Wednesday, August 20, 2008 10:40 AM OP doesn't revert back
    Wednesday, August 13, 2008 5:50 PM

All replies

  • Could you please show the code on how you refresh the ItemsSource property in a timely fashion? I think you need to nullify it (aka listview.ItemsSource = null) before assign its value using listview.ItemsSource = _myDB.tblInspectionStatus.

    Monday, August 18, 2008 8:45 AM
  • We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by clicking the "Options" link at the top of your post, and selecting "Change Type" menu item from the pop menu. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


    Thank you!

    Wednesday, August 20, 2008 10:39 AM