User (Old forums)MemberMarch 17, 2008 at 5:14 amPost count: 23064
My problem is, that I get an exception all the time, when i try to add a new row using the built in GUI functionality of the DataGrid (WPF version), which says: the underlaying data source doesn’t support insertion.
I used LINQ to SQL for geting the data from the DB and I proiveded the result directly as ItemSource, which worked fine, all the rows are shown correctly, can be edited and persisted into the DB using LINQ again, only the new row can’t be added 🙁
I’m not sure, where the problem is.
– in the DataGrid or in some settings of it
– in the way I bind it to the data source
– in the data source
What I miss is: where can I define the so called template for the new item (not visualy, but at code level, so the class initialization), at least somewhere I have to be able to provide a type to the DataGrid wich has a parameterless constructor.
Any suggestions are welcome!
Sorry for that, if this topic has been already written somewhere, in this case a link whould be a big help for me!
Thx in advance
Imported from legacy forums. Posted by László (had 2667 views)Xceed SupportMemberMarch 17, 2008 at 8:55 amPost count: 5658
Insertion is currently only supported if the data source implements IBindingList. That said, use the GetNewBindingList method on the result returned from the query and bind to that list instead.
Imported from legacy forums. Posted by Jenny [Xceed] (had 899 views)User (Old forums)MemberMarch 17, 2008 at 11:27 amPost count: 23064
Thx, it helped!
Interesting, that it automaticaly filled the PK key field with value 0 (the PK column’s type is integer), and didn’t leave it as empty (null), but after saving it, the row has been refreshed to the correct IDENTITY field value geven by the SQL server…
Imported from legacy forums. Posted by László (had 2743 views)User (Old forums)MemberApril 18, 2008 at 3:55 pmPost count: 23064
I was having the same problem. I fallowed your instruction, but I’m still having a problem. I can insert a row and the PK_Id show automaticly 0. But can not edit the others fields. I’m using VB
Private db As New LinqSQLDataContext
Private Sub Principal_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim b As New Binding
Dim l As New DataGridCollectionView(db.Table1.GetNewBindingList)
b.Source = l
Imported from legacy forums. Posted by Etienne (had 2397 views)
- You must be logged in to reply to this topic.