This is a migrated thread and some comments may be shown as answers.

Database not updated from Editform

1 Answer 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kermit
Top achievements
Rank 1
Kermit asked on 11 Jan 2012, 10:52 PM
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

1 Answer, 1 is accepted

Sort by
0
Kermit
Top achievements
Rank 1
answered on 12 Jan 2012, 05:54 PM
Never mind... I figured out that if I specified the table key field in the DataKeyNames property for the radGrid, the problem went away.
Tags
Grid
Asked by
Kermit
Top achievements
Rank 1
Answers by
Kermit
Top achievements
Rank 1
Share this question
or