Hello,
I have created a web page with a FormView that allows me to add and edit data in my database. I configured the SqlDataSource control and it populated the SELECT, INSERT, UPDATE and DELETE statements. I've created a stored procedure to do the INSERT and return to new identity value. My question is this: Can I configure the control to use this stored procedure? If so, how? Or do I have to write some code for one of the event handlers (inserting, updating?)
Any help would be appreciated.
-brian
Yes you can. Not seeing your code makes it difficult to diagnose, but it sounds like you have the SqlDataSource partially set up. Make sure you also have the insertcommand attribute set to your new stored procedure and the insertcommandtype set to "StoredProcedure". The InsertParameters should also be set to include any input parameters that are not explicitly bound within the FormView.InsertItemTemplate.
From here, you need to make sure the FormView is in insert mode, your InsertItemTemplate is properly set up, and you have an insert button with the CommandName attribute properly set to "Insert".
Once you click that button, the FormView.ItemInserting event will fire, then the SqlDataSource.Inserting event will fire.
Assuming you have all of your stored procedure input parameters properly set up within your ASPX page, your stored procedure should run, and you can pick up your return parameter from the SqlDataSource.Inserted event.
Hope this helps.
No comments:
Post a Comment