Microsoft Developer Network > Forums Home > Archived Forums Forums > LINQ Project General > Simple LINQ & GridView Question - how to edit data?
Ask a questionAsk a question
 

AnswerSimple LINQ & GridView Question - how to edit data?

  • Thursday, February 28, 2008 1:03 AMdhurwitz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Hi,

    I am just beginning to work w/ LINQ. I have a data model set up and put a LinqDataSource and GridView on a page. It binds & displays ok, including paging and sorting.

     

    How do I enable editing? I followed a blog by ScottGu to edit using the GridView. Clicking on the smart tag of the GridView in Design view, there are no checkboxes to enable editing or deletion, as there would be for a SqlDataSource bound grid. I thought the LinqDataSource enabled two way binding, similarly to the SqlDataSource. Is this not correct?

     

    If it is correct, how to do I enable editing? I have configured the LinqDataSource to enable automatic deletes, inserts and updates. I have also tried manually adding a CommandField column to the GridView. Nothing seems to work. Here is the markup for the LinqDataSource:

     

    <asp:LinqDataSource ID="LinqDataSource1" runat="server"
        ContextTypeName="AdventureWorksDataContext"
        EnableDelete="True" EnableInsert="True" EnableUpdate="True"
        Select="new (ProductID, Name, MakeFlag, SafetyStockLevel, ReorderPoint)"
        TableName="Products">
    </asp:LinqDataSource>

     

     

    Thanks.

     

    Dan

Answers

All Replies