Passing an object to the Business Logic in my ObjectDataSource.SelectMethod

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frankiefrank
    New Member
    • Jan 2008
    • 15

    Passing an object to the Business Logic in my ObjectDataSource.SelectMethod

    Hi, (ASP.NET question)

    I'm using an ObjectDataSourc e on a DataGridView for a custom paging/sorting scenario. I implemented a method that gets the parameters for the paging (number of rows to retrieve, index of first row) and the SortingExpressi on.

    In my page I have a lot of controls, used to determine which data I have to select from the DB. Since I'm using the custom paging, I had to make a static method that gets the above mentioned parameters. I used a static object - a collection of parameter values (retrieved from the page before calling DataBind). I now understand that this is bad practice - since everyone using the page is accessing the same static object of latest parameter values.

    So now I need a way to pass that object into the static method. Any ideas on how to do it?
  • frankiefrank
    New Member
    • Jan 2008
    • 15

    #2
    Anyone? Would still appreciate any help on the issue...

    Thanks,
    Frankie

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Um...passing an object into a method is the same as passing any other parameter....

      [Code=vb]Private Sub MyMethod(ByVal Param As Object)
      Dim oClass As MyClass = CType(Param, MyClass)

      //Do stuff with oClass

      End Sub[/Code]

      Is that what you meant?

      Comment

      • frankiefrank
        New Member
        • Jan 2008
        • 15

        #4
        Originally posted by balabaster
        Um...passing an object into a method is the same as passing any other parameter....

        [Code=vb]Private Sub MyMethod(ByVal Param As Object)
        Dim oClass As MyClass = CType(Param, MyClass)

        //Do stuff with oClass

        End Sub[/Code]

        Is that what you meant?
        Nope, I'm not THAT new to programming :)

        Take a look at the ObjectDataSourc e property SelectMethod:


        The method name you provide for the ObjectDataSourc e is the name of a static method. When a DataBind occurs the DataGridView (bound the ObjectDataSourc e) calls the Select method to get data - but since it's Static (required) I can't access my non-static members (with this keyword.

        Hope my problem is clearer now...

        Comment

        Working...