How to implement IDataSource interface for a custom generic collection in C#
I am using DataView in SharePoint. I want to bind a collection of objects to the DataView. But when I am trying to bind it is giving the error that the collection does开发者_C百科 not implement IDataSource interface. Can anybody tell me how to extend the collection class to implement IDataSource interface?
Thanks Ashwani
An interface is a public contract- implementing an interface means that the class implements each of the methods declared in the interface. Your collection class will have to be defined as implementing IDataSource:
public class MyClass : IDataSource
and then implement each IDataSource method:
DataSourceView IDataSource.GetView(string viewName)
{
//your code here
}
...etc.
See MSDN for more details
精彩评论