Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
LINQ to SQL in UltraWinGrid
posted

Hi,

I'm using a LINQ to SQL Object in an UltraWinGrid as DataSource. Almost everything works fine but there is one problem:

If You add a new line to the LINQ Object or if You remove an existing line  from the LINQ object by code (not in the grid itself), the grid doesn't react. It doesn't remove removed line and doesn't show new lines. Event setting the DataSource of the grid to nothing and back to the LINQ Object doesn't help.

If I do the same with a DataTable as DataSource it works fine.

Is there a way to solve this problem?

Thanks,

Udo

 

 

 

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi Udo,

    The grid binds to two types of data sources: IList and IBindingList. The IBindingList interface is much more robust and provides notifications to the BindingManager when rows are added or removed. IList does not provide these notifications. So it sounds to me like the data source you are using an IList and not an IBindingList.

    I'm not a LINQ to SQL expert - perhaps there is some way to coerce the returned data into a IBindingList or BindingList<>. If so, that would be the best way to handle this.

    If not, then one alternative would be to notify the grid of the changes yourself. Any time you add or a remove a row, you can call grid.Rows.Refresh(ReloadData) and the grid will refresh the display based on the current data in the data source.

Reply Children