如何以编程方式触发 ObjectDataSource 的插入事件(与 DataBound 控件相反)
我有一个向导控件,可以通过 7 个步骤收集数据。第7步有一个ObjectDataSource。当用户单击完成按钮时,我希望 ObjectDataSource 控件触发其插入事件,以便数据可以传递到下划线方法并最终保存到数据库。
我该怎么做?
<asp:ObjectDataSource ID="UploadPhotoObjectDataSource" runat="server"
DataObjectTypeName = "PhotoData" TypeName = "ImagesBLL.cs"
InsertMethod = "AddImage">
</asp:ObjectDataSource>
感谢您的帮助
I have a wizard control that collects data over 7 steps. There's a ObjectDataSource at the 7th step. When the user clicks the finish button, I want the ObjectDataSource Control to fire its Inserting event so that data can be passed to the underline method and eventualy be saved to the database.
How do I do that?
<asp:ObjectDataSource ID="UploadPhotoObjectDataSource" runat="server"
DataObjectTypeName = "PhotoData" TypeName = "ImagesBLL.cs"
InsertMethod = "AddImage">
</asp:ObjectDataSource>
Thanks for helping
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你不能根据这个线程:
为什么在派生类中不能像在 C# 中的基类中一样使用事件?
触发 Inserting 事件而不是执行实际插入是你可以迈出的一步希望重新考虑。调用Insert会触发Inserting事件(插入数据后,会触发Inserted事件)。
I don't think you can according to this thread:
Why events can't be used in the same way in derived classes as in the base class in C#?
Triggering the Inserting event instead of doing an actual insert is a step you may wish to reconsider. Calling Insert will trigger then Inserting event (and after the data is inserted, the Inserted event).