We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to refresh the datagrid when new items are added.

Thread ID:





123442 Mar 17,2016 03:09 PM UTC Apr 26,2016 04:04 PM UTC UWP 4
Tags: SfDataGrid
Garling Beard
Asked On March 17, 2016 03:09 PM UTC

I am using a datagrid to display items from an SQLite DB, I have set my databinding as follows:

<Grid:SfDataGrid x:Name="gridOrderDetails" HorizontalAlignment="Left" Height="650" Margin="10,325,0,-15" VerticalAlignment="Top" Width="1420"
                         ItemsSource="{Binding OrderDetails}"

public class vmOrderDetails
        private ObservableCollection<dmOrderDetails> _orderDetails;

        public ObservableCollection<dmOrderDetails> OrderDetails
            get { return _orderDetails; }
            set { _orderDetails = value; }

        public vmOrderDetails()
            _orderDetails = new ObservableCollection<dmOrderDetails>();

        private void DisplayOrder()
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "cust.db");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
                var itemDetailQry = from p in conn.Table<orderDetails>()
                              where p.ORDERNUMBER == DataClass.orderDetailOrderNumber
                              select new
                                  ItemDesc = p.ITEMDESC,
                                  ItemQty = p.ITEMQTY,
                                  ItemCost = p.ITEMCOST,
                                  ItemNum = p.ITEMNUM,
                                  ItemStatus = p.ITEMSTATUS,
                                  ItemSeq = p.ITEMSEQ,
                                  ItemOrderNumber = p.ORDERNUMBER,

                foreach (var d in itemDetailQry)
                    _orderDetails.Add(new dmOrderDetails(d.ItemSeq, d.ItemNum, d.ItemQty, d.ItemDesc, d.ItemCost, d.ItemStatus, d.ItemOrderNumber));


How can I run a function to refresh the data after I add a new item to the database?

Garling Beard
Replied On March 17, 2016 07:56 PM UTC

I removed the databinding in the XAML and did it in C#, it is now working. 

Srinivasan Vasu [Syncfusion]
Replied On March 21, 2016 01:15 AM UTC

Hi Garling,

Thanks for contacting Syncfusion support.

We have analyzed your query and we have prepared a sample as per your requirement. In this sample, we have added new items in collection and  our SfDataGrid refreshed automatically. In Observable collection, the collection implements the INotifyCollectionChanged interface. So SfDataGrid will be refreshed automatically when Add items in collection. Could you please update more information on reported problem like modifying the above sample or provide issue reproducing sample to us? It would be better for us and provide a better solution.

Sample: http://www.syncfusion.com/downloads/support/forum/123442/ze/DataGrid_Refreshed1752256830


Replied On April 25, 2016 06:41 AM UTC

I'm having the same issue. Binding via C# works fine but via XAML it doesn't.

Jai Ganesh S [Syncfusion]
Replied On April 26, 2016 04:04 PM UTC

Hi Garling, 
In our previous updated sample, we have bound the ItemsSource in XAML and add a records to a collection dynamically from code behind. This works as expected in our side. If this is not your requirement, then could you please share the more information about your requirement? This would be more helpful for us to analyze further. 
Jai Ganesh S 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon