ASPNet and custom parameter for datasource controls
ASp.net 2.0 introduces datasource controls, such as SqlDataSource and ObjectDataSource, these controls work quite well, expecially the objectDataSource that permits you to bind to methods of a custom object. In an application of mine there is a user control that has a datagrid with custom logic, that data should be enclosed in different pages, and the control support filtering records. The problem is that in some page we need to be able to pass a parameter to querystring to set the filter, in other pages we have a series of control used by the user to set the filter. The obvious solution is to create a custom parameter object to support this situation.
|
|
The control is really simple, it inherit from the standard ControlParameter, and it defines another property called QueryStringPath used to specify the key in the querystring that contains the parameter. The core of the work is done overriding the Evaluate function, first I check if the data is in the querystring (that is prioritary), if not I check if the control exists using a recursive function called RecFindControl, then if the control does not exists I simply return nothing, if the control exists I delegate the work to the base class.
With this parameter I can solve my problem
alk.
Tags: ASP.Net DataSource