Database not updated from Editform

2 posts, 0 answers
  1. Kermit
    Kermit avatar
    20 posts
    Member since:
    Jan 2012

    Posted 11 Jan 2012 Link to this post

    I have a simple SQL table with about 10 fields driving an ajaxed radgrid via a SqlDataSource as follows:

     

     

    <asp:SqlDataSource ID="SqlDataSource_gvSalesRep" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
       SelectCommand="Select * From SalesRep" 
       UpdateCommand="Update SalesRep Set [Phone_No] = @Phone_No Where [Slspsn_No] = @Slspsn_No">
       <UpdateParameters>
          <asp:Parameter Name="Phone_No" />
          <asp:Parameter Name="Slspsn_No" />
       </UpdateParameters>
    </asp:SqlDataSource>

    I want only 1 of the 10 fields (Phone_No) to be editable on the editform, so I set the other 9 fields to readonly. When I change the phone number on the editform and click update, the change is not made on the database nor on the radgrid.  If I remove readonly from the 9 fields and then change the phone number on the editform and click update, the change occurs on the database and the radgrid.

    Why would that be, and what is the solution?

    Thanks

  2. Kermit
    Kermit avatar
    20 posts
    Member since:
    Jan 2012

    Posted 12 Jan 2012 Link to this post

    Never mind... I figured out that if I specified the table key field in the DataKeyNames property for the radGrid, the problem went away.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top