I have a form view which is inserting data into a sql-server-2008 database. instead of using the formview’s functionality of entering data into the database, i would like it to use my own data access layer. since i am a beginner at asp.net i do not understand how to intercept the INSERT and do my own insert. i need to grab text out of the text boxes and process the data myself.
question: at which point do i intercept the INSERT (after the user clicks on the INSERT link)? where exactly do i add my own code?
RECOMMENDED SOLUTION
I think you’ve gone a little beyond the scope of the control if you need to control the actual insert command. At this point, you should move to just handling a button click event and invoke your DAL directly, from such a control as a
<asp:Button/>and perhaps use another UI control if you are dependent on theFormViewcontrol to present the UI.THE BELOW IS A HACK – Only do as a last resort
However, you could ‘hack’ the
FormViewcontrol by attaching to theItemInsertingevent, and then insert via your DAL. Then you would simply “Cancel” the insert by setting theCancelproperty to true: