Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Insert a new row using LINQ

Sort Posts: Previous Next
  •  04-25-2008, 9:07 AM Post no. 11734

    Insert a new row using LINQ

    You have many topics in this forums about inserting row with LinqToSQL.  I fallowed all your instructions, I'm using VB and her's the code:

    Private db As New LinqSQLDataContext

    Private Sub Page1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded

    Dim b As New Binding

    Dim c As New DataGridCollectionView(db.Table1.GetNewBindingList)

    b.Source = c

    Me.DataGridControl1.SetBinding(DataGridControl.ItemsSourceProperty, b)

    End Sub

    I can insert a row and the PK_Id show automaticly 0.  But it stop there, I can not edit the others fields of the inserted row.  All the others rows works fine, I can edit and SubmitChange, sort and filter, but not insert a row.  Can you help me !

  •  04-25-2008, 9:18 AM Post no. 11736 in reply to 11734

    Re: Insert a new row using LINQ

    Have you set the AutoCreateColumns property to false? If so, cell editors need to be explicitly provided for each column in order to support insertion (see Column.CellEditor property).


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
    Filed under:
  •  04-25-2008, 10:24 AM Post no. 11739 in reply to 11736

    Re: Insert a new row using LINQ

    Yes, AutoCreatColumns = False, if I set it to True, it works fine.  I will take a look at the Column.CellEditor.  Can I hide and rename columns in AutoCreatColumns = True mode direcly in my VB code when Page1.Loaded ?
  •  04-25-2008, 10:29 AM Post no. 11740 in reply to 11739

    Re: Insert a new row using LINQ

    Yes, you can hide columns by setting their Visible property even if AutoCreateColumns is set to true; however, what I suggest you do if you don't need to extra columns is to explicit define only the DataGridItemProperty objects you want in your DataGridCollectionView. The defined item properties correspond to the columns that will be in your grid.
    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  04-25-2008, 11:30 AM Post no. 11748 in reply to 11740

    Re: Insert a new row using LINQ

    Tanks for your help
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.