views:

215

answers:

6

I'm trying to create a custom class that is based off of an XML file (using xsd.exe). The end goal of this class is to bind it to a UI element (probably a gridview or something like that - I haven't decided yet). Are there any interfaces that I need to be sure to implement in order to do this? I would think IEnumerable would be a key one, but I can't be sure.

Any thoughts?

edit : Sorry about that, the target deployment is ASP.NET 3.5

A: 

WinForm? WPF?

In Winform IBindingList is one of significant interest for lists of objects to grids.

Quibblesome
A: 

Like Quarrelsome said if this custom class is a collection then IBindingList would be needed. For other classes INotifyPropertyChange is useful because any changes made to your object through code, like clearing fields when button is clicked will update the UI automatically. If you're using WPF you could possible add DependencyProperties to your class and bind to those, which I'm pretty sure will get rid of the need to INotifyPropertyChanged. If your using ASP.NET then you can't make use of INotifyPropertyChange. I'd like to give a specific answer but unless I know the UI technology (WPF, WinForms, ASP.NET web forms, ASP.NET MVC, Silverlight) you'll be using I just have to cover the basics.

wegrata
+1  A: 

Since your in ASP.Net the basic thing is to implement IEnumerable, you can then bind to any properties on your POCO.

JoshBerke
A: 

ICustomTypeDescriptor

Curt Hagenlocher
+1  A: 

You don't need any speciall interfaces for your object. In ASP.NET you don't have two directional binding.

You want to bind you control to a list implements IEnumerable.

Emil C
+1  A: 

If you're going to be using XSD.exe to generate the class, you can use the /edb switch and the databinding code will be generated automatically.

Disclaimer: I've only used this in a quick test project, but never went further than that.

NYSystemsAnalyst