I've done this a number of times, but I can't figure out why I can't get it to work on this one. I have a gridview control that the user can select one of the items and then a detailsview control is populated with the item's details for editing/updating.
I have some templatefields in the detailsview with some dropdownlists and textbox controls. In the detailsview control's itemupdating event, I assign some values to the parameters for the templatefield controls.
Everything seems to run fine. When I check the values in the itemupdating event, everything is just as it should be. There are no errors generated but the database is not updated. Any help is greatly appreciated.
Protected Sub dvUAHAComponent_ItemUpdating(sender As Object, e As DetailsViewUpdateEventArgs) Handles dvUAHAComponent.ItemUpdating
Call Delete_Code_References()
Call UpdateCodeReferences()
Dim ddl1 As DropDownList = DirectCast(Me.dvUAHAComponent.FindControl("ddlUAccess"), DropDownList)
Dim ddl2 As DropDownList = DirectCast(Me.dvUAHAComponent.FindControl("ddlUOp"), DropDownList)
Dim ddl2B As DropDownList = DirectCast(Me.dvUAHAComponent.FindControl("ddlUHazard"), DropDownList)
Dim chk1 As CheckBox = DirectCast(Me.dvUAHAComponent.FindControl("chkUOp"), CheckBox)
Dim txt1 As TextBox = DirectCast(Me.dvUAHAComponent.FindControl("txtUOp"), TextBox)
Dim lst1 As ListBox = DirectCast(Me.dvUAHAComponent.FindControl("lstCodes"), ListBox)
Dim ddl3 As DropDownList = DirectCast(Me.dvUAHAComponent.FindControl("ddlUTrade"), DropDownList)
Dim ddl4 As DropDownList = DirectCast(Me.dvUAHAComponent.FindControl("ddlUJurisdiction"), DropDownList)
Dim ddl5 As DropDownList = DirectCast(Me.dvUAHAComponent.FindControl("ddlURAC"), DropDownList)
e.NewValues("ID") = CInt(gvAHAMain.SelectedDataKey.Value) 'Gets the ID# for the AHA Item from the AHA gridview control
e.NewValues("Access") = ddl1.SelectedItem.Text
If chk1.Checked = True Then 'It's a new Operation that has been entered into the textbox control
e.NewValues("Op") = txt1.Text
ElseIf chk1.Checked = False Then 'It's an existing Operation that has been entered into the textbox controll
e.NewValues("Op") = ddl2.SelectedItem.Text
End If
e.NewValues("Hazard") = ddl2B.SelectedItem.Text
e.NewValues("Trade") = ddl3.SelectedItem.Text
e.NewValues("Jurisdiction") = ddl4.SelectedItem.Text
e.NewValues("RAC") = ddl5.SelectedItem.Text
End Sub
Member
11 Points
89 Posts
Detailsview Update Doesn't Update Database
Jun 15, 2016 04:55 AM|mavila|LINK
I've done this a number of times, but I can't figure out why I can't get it to work on this one. I have a gridview control that the user can select one of the items and then a detailsview control is populated with the item's details for editing/updating. I have some templatefields in the detailsview with some dropdownlists and textbox controls. In the detailsview control's itemupdating event, I assign some values to the parameters for the templatefield controls.
Everything seems to run fine. When I check the values in the itemupdating event, everything is just as it should be. There are no errors generated but the database is not updated. Any help is greatly appreciated.
Here's the detailsview control:
Here is the SqlDataSource control:
Here is the ItemUpdating event:
All-Star
194030 Points
28033 Posts
Moderator
Re: Detailsview Update Doesn't Update Database
Jun 15, 2016 07:15 AM|Mikesdotnetting|LINK
Have you tried using Sql Profiler to see a) if any SQL commands are executed and b) what they contain?
Member
11 Points
89 Posts
Re: Detailsview Update Doesn't Update Database
Jun 15, 2016 06:00 PM|mavila|LINK
Thank you. I'm not familiar with that. I will check it out.