Some quick background on what I'm working on:
My question is as follows: Is it possible to somehow "intercept" the collection returned from the ObjectDataSource so I can manipulate the collection before it is passed to the RadGrid?
If this isn't possible; it's not a dealbreaker. I believe I can modify the Select() method to accept the two lists; and perform the manipulation there. Another avenue I have is to implement the NeedDataSource() event for the grid, and manipulate there as well.
Ideally, I'd like to use the first option. Has anybody been successful doing this before?
You can derive from ObjectDataSource & ObjectDataSourceView, and respectively override GetView & ExecuteSelect, something like this:
public class MyObjectDataSource : ObjectDataSource
{
private MyObjectDataSourceView _view;
private MyObjectDataSourceView GetView()
{
if (_view == null)
{
_view = new MyObjectDataSourceView(this, "DefaultView", Context);
if (IsTrackingViewState)
{
((IStateManager)_view).TrackViewState();
}
}
return _view;
}
protected override DataSourceView GetView(string viewName)
{
return GetView();
}
}
public class MyObjectDataSourceView : ObjectDataSourceView
{
public MyObjectDataSourceView(MyObjectDataSource owner, string name, HttpContext context)
: base(owner, name, context)
{
}
protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
{
IEnumerable dataSource = base.ExecuteSelect(arguments);
// TODO: do your stuff here
return dataSource;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With