Hello,
I'm trying to add new row to the xamWebGrid, which is binded through ria control in xaml (entity framework). I read (from this forum) that this was not yet provided for this control, so I'm looking another way to do it. Since the ItemsSource should be of IList type, I don't know how to actually get the data and cast it to this type;
Here is what I'm trying to do (in the constructor of the page):
MyContext ctx = new MyContext();this.ContractManagementGrid.ItemsSource = ctx.ContractGridDatas.ToList();ctx.Load(ctx.GetContractGridDataQuery());
In this stage, ctx.ContractGridDatas is empty, and nothing is shown on my page when run. However, if I remove ".ToList()" from the statement, everything works perfectly, but with exception thrown after adding new row, of course... When is the data populated in the ItemsSource property?
Scince I'm using custom entity (entity name: Contract, gathering data from different tables), can you please tell me what should be the right procedure for updating/deleting/adding records from the grid and affecting the DB respectively?
Thanks
What is the exception that you are getting?
Could you post the exception message?
Hi Darrel and thanks for your reply;
The exception name is: Infragistics.Silverlight.DataSourceDoesNotSupportIListException (as stated in http://community.infragistics.com/forums/t/30552.aspx);
Recently, I have found out that the data is loaded after all Loaded events are completed;
So, as a workaround, I had to put a button to load the data, get my context filled, convert the data to IList and re-bind the ItemsSource property. Now the exception is gone, and the functionality is ok.
Can I avoid the button usage, and have the data loaded on the beginning?
Hi,
What you could do is if there is a Loaded event for the data from the RIA services to hook up this event and then use the ToList() on the loaded data.
However, note that ToList() creates different object, so when you change the data in the Grid it will not update your RIA services data and vice versa.
HTH,
Thanks Stoimen,
the Loaded event was what I needed.