开发者

form view - inserting using my own DAL

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 the FormView control to present the UI.

THE BELOW IS A HACK - Only do as a last resort

However, you could 'hack' the FormView control by attaching to the ItemInserting event, and then insert via your DAL. Then you would simply "Cancel" the insert by setting the Cancel property to true:

void EmployeeFormView_ItemInserting(Object sender, FormViewInsertEventArgs e)
{
     // Do Stuff
     e.Cancel = true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜