1

i put all my custom "update" code in the RowCommand event, it works fine, but i still get an error from my Data Source

System.NotSupportedException: Updating is not supported by ObjectDataSource 'GetSources' unless the UpdateMethod is specified.

how can i get rid of that error , yes still use my custom update code on the rowcommand?

4

1 回答 1

0

好吧,我认为 ObjectDataSource 的使用方式是您在自定义业务对象中指定方法的名称,它将使用反射来调用该方法。

因此,您的页面和对象可能如下所示:

<asp:objectdatasource
              id="ObjectDataSource2"
              runat="server"
              updatemethod="MyUpdateMethod"
              typename="MyBusinessObject">
<updateparameters>
<asp:controlparameter name="anID" controlid="DropDownList1" propertyname="SelectedValue" />
</updateparameters>
</asp:objectdatasource>

Public Class MyBusinessObject

    Public Shared Sub MyUpdateMethod(anID As String)
    'data access code
    End Sub 

End Class

这种将控制放在一起的模式可能非常有成效,但一段时间后你可能会觉得太受限制了。

于 2011-03-31T16:21:41.770 回答