开发者

How to implement IDataSource interface for a custom generic collection in C#

开发者 https://www.devze.com 2023-01-20 21:11 出处:网络
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 IDataS

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

0

精彩评论

暂无评论...
验证码 换一张
取 消