Passing complex object parameter to ObjectDataSource Select

混江龙づ霸主 提交于 2020-01-05 09:21:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!