Questions and Answers on any aspect of .NET. Now closed.
I want a generic method that will accept a XmlNodeList and one of the repeating ASP.Net controls: DataGrid, DataList, Repeater, etc.
I thought that all of those would implement some kind of "IBindable" interface which would ensure I had "DataSource" and "DataBind" properties, however I can't find anything like this.
Thoughts on how to handle this? In my head, it looked like this:
public void SetDataSource(IBindable Control, XmlNodeList TheData)
Control.DataSource = TheData;
Again, in my head, this method would accept a Repeater, DataGrid,or DataList equally. Reality, sadly, has not been as kind as I hoped.
I suppose I could overload the method, but that's not nearly as cool.
Thursday, January 25, 2007
None of those classes appear to be sealed. So you could inherit from each one, and implement your own interface in the inheriting class. Then you use your derived classes in your project in place of the regular ones.
Granted, that seems like a bit more trouble than just overloading.
If you overload, you won't have to do an overload for each control; some of the controls have base classes like BaseDataList or BaseDataBoundControl.
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz