understanding the interface contract for a DataSource

A

Andy Fish

Hi,

I'd like to implement my own datasource (specifically for an asp.net
ListControl) but I'm not having much luck finding documentation on how to go
about it.

The type of the datasource property on most controls is simply "object", but
clearly there must be some interface contract I have to implement to get a
datasource to work properly.

I read something in MSDN saying a DataSource must implement IList but that's
clearly not the case because, for instance, DataTable doesn't implement
IList.

Andy
 
T

Teemu Keiski

Hi,

the crucial interfaces in databinding are IListSource and IEnumerable (which
all collections do implement)
 
A

Andy Fish

so a datasource must implement either one of these two?

I implemented IEnumerable so I have actually got my solution working, but I
would still like to locate some definitive statement in the documentation
(I'm just that kind of guy :)

Thanks

Andy
 
T

Teemu Keiski

Yes, either one. DataSet and DataTable for example implement IListSource but
not IEnumerable. Framework uses a helper class & method for data source
resolving in data bound controls and this class checks first for IListSource
interface (and if given data source implements it, digs the actual IList
from IListSource implementation) and if that isn't implemented, then for
IEnumerable.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top