views:

348

answers:

2

I have a partial class (the main class is a LinqToSql generated class)

   <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

Here is the method it's calling

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

I want to use the ObjectDataSource to drive a DropDownList.

  <asp:ObjectDataSource ID="contractOds" runat="server" 
         TypeName="MBI_Contract"
         SelectMethod="GetCancelableContracts" 
         DataObjectTypeName="Dealer">
    </asp:ObjectDataSource>

My aspx page has a Dealer property that is set in a BasePage. My question is how can I pass this property(object) to the ObjectDataSource, so it can be evaluated in my select method. Does anyone know how I can do this? Or am I totally doing this the wrong way?

Thanks for any Advice, Cheers, ~ck in San Diego

+1  A: 
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

This seems to work.

Hcabnettek
A: 

you can try this code...

 Protected Sub contractOds_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles contractOds.Selecting
        e.InputParameters["dealer"] = Dealer;
    End Sub
Muhammad Akhtar
this is written in VB.NET so I cannot put c# code inside the method, but yes this is the right idea. I have it working now. Thank you Muhammad. :)
Hcabnettek