"FormView must be insert mode to add a new record" -- but I want to update a record

Last post 10-20-2008 12:00 PM by adamoneil1. 1 replies.

Sort Posts:

  • "FormView must be insert mode to add a new record" -- but I want to update a record

    10-20-2008, 11:51 AM
    • Member
      6 point Member
    • adamoneil1
    • Member since 03-11-2007, 9:25 PM
    • Posts 35

    I have a form view that's complaining that it "must be in insert mode to add a new record" -- but I'm trying to update a record that's already successfully displayed -- having rendered the EditItemTemplate. The data binding seems to be working otherwise, but for some reason the FormView thinks I'm trying to insert, when I'm actually trying to update.

    The FormView's default mode is Insert, but in the Load event, I change the mode to Edit depending on the presence of a QueryString field. As far as I can tell, the mode change is successful because the EditItemTemplate renders as expected.

    I've tried playing around with the DataKeyNames property of the FormView. I have it set to the name of the parameter from my SqlDataSource's UpdateParameters that is the key field for the update.

    I'm pretty confused. Any help appreciated.

  • Re: "FormView must be insert mode to add a new record" -- but I want to update a record

    10-20-2008, 12:00 PM
    • Member
      6 point Member
    • adamoneil1
    • Member since 03-11-2007, 9:25 PM
    • Posts 35
    Never mind. I figured this out. I had copied the markup from my InsertItemTemplate--including a button whose CommandName was Insert. I was trying to use an Insert button in the Edit template.
Page 1 of 1 (2 items)