tdean
tdean

Reputation: 558

Passing complex object parameter to ObjectDataSource Select

I am using an ObjectDataSource and I would like to pass a custom object as the select parameter.

Here is my DL method:

public static Collection<AdminUserEntity> GetUsers(ClientEntity currentClient)
{
}

So when I configure my ObjectDataSource I choose the AdminUserEntity as the buisness object to bind to and then choose GetUsers as the Select method but as you see it takes a complex type as a parameter and I don't know how to specify this using the wizard or manually.

After some more digging I found this solution:

protected void ods_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
     ClientEntity currentClient = ClientEntity.GetClient("abc");
     e.InputParameters["currentClient"] = currentClient;
}

Are there any other ways to accomplish this or is this a good solution?

Upvotes: 1

Views: 8263

Answers (1)

Mike
Mike

Reputation: 2922

Take a look at the bottom of this article: http://msdn.microsoft.com/en-us/library/57hkzhy5(v=vs.80).aspx

You'll want to use the DataObjectTypeName property on the ObjectDataSource control. This will be the name of the custom object.

Either solution should work just fine.

Upvotes: 2

Related Questions