我有一个部分类(主类是LinqToSql生成的类)
<DataObject(True)> _
Partial Public Class MBI_Contract
<DataObjectMethod(DataObjectMethodType.Select, True)> _
Public Shared Function GetCancelableContracts(ByVal dealer As Dealer) As List(Of MBI_Contract)
Return Utilities.GetCancelableContractsForDealer(dealer)
End Function
End Class
这是它正在调用的方法
Public Function GetCancelableContractsForDealer(ByVal dealer As Dealer) As List(Of MBI_Contract)
Dim db As TestDataContext = TestDataContext.Create()
Return (From mbi As MBI_Contract In db.MBI_Contracts _
Where mbi.MBI_DealerNumber = dealer.DealerNumber _
AndAlso mbi.MBI_PaidFor = True _
AndAlso mbi.MBI_Deleted = False).ToList()
End Function
我想使用ObjectDataSource来驱动DropDownList。
<asp:ObjectDataSource ID="contractOds" runat="server"
TypeName="MBI_Contract"
SelectMethod="GetCancelableContracts"
DataObjectTypeName="Dealer">
</asp:ObjectDataSource>
我的aspx页面有一个在BasePage中设置的Dealer属性。我的问题是如何将此属性(对象)传递给ObjectDataSource,因此可以在我的select方法中进行评估。有谁知道我怎么做到这一点?或者我完全以错误的方式做这件事?
感谢任何建议, 干杯, 〜在圣地亚哥
答案 0 :(得分:1)
Protected Sub contractOds_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles contractOds.Selecting
e.InputParameters.Insert(0, "dealer", Dealer)
End Sub
这似乎有效。