问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/11697187/passing-complex-object-parameter-to-objectdatasource-select