Detailsview updating does not work
I have a Transactions table which stores individual items that the user selects for purchase (item name, item price, order ID, etc) I have an Orders table which stores values for the Order (account name, order total, etc) Here is my Sql Data Source as defined in the page: " Insert Command="INSERT INTO [tbl Orders] ([Order Date], [Order Total], [Order Account], [Order Cost Centre]) VALUES (@Order Date, @Order Total, @Order Account, @Order Cost Centre); SELECT @Order New ID = SCOPE_IDENTITY()" Select Command="SELECT * FROM [tbl Orders]" Update Command="UPDATE [tbl Orders] SET [Order Date] = @Order Date, [Order Total] = @Order Total, [Order Account] = @Order Account, [Order Cost Centre] = @Order Cost Centre WHERE [Order ID] = @original_Order ID AND [Order Date] = @original_Order Date AND [Order Total] = @original_Order Total AND [Order Account] = @original_Order Account AND [Order Cost Centre] = @original_Order Cost Centre" Old Values Parameter Format String="original_" oninserting="Sql Data Source2_Inserting" oninserted="Sql Data Source2_Inserted" onupdated="Sql Data Source2_Updated" onupdating="Sql Data Source2_Updating" //Update Order Table with Total of Order //Sql Data Source2.
Update(); The page doesn't error out, but the Update to Order Total in the Orders Db doesn't update. Or, tap into the Updating event, and add the new value to the event argument collection of values.
Still nothing happen and no error except insert part where it say cannot insert null value which I already did by select value from dropdownlist. I have to go to Edit Data Binding to set it target to specific column.
I don't get it why because I select the editing option, same for insert and delete. All I do is change some input like replace textbox to Dropdownlist in Edit Template. Before, it left it blank that is why it not change anything.
In order to update an existing record, assign the value True to the Details View controls Auto Generate Edit Button property .In other words, it contains the original values of the object which is changed in the Details View.I use all data Bound Field in Details View from SQL Server.A Visual Studio project with source code is available to accompany this topic: Download.During this walkthrough, you will learn how to: The next step is to create and configure a data source control that can be used to query the database.