views:

196

answers:

1

I am working on a project at the moment where we are building templated data-bound controls (TDBC) for ASP.NET.

The problem is it appears that nobody has really worked out the definitive pattern for how to do this - there are 3 or 4 different 'styles'.

Not only that but many of the controls are giving the "cannot use databinding when control is not on a page" error at design time, so obviously something is being done wrong in those controls.

Here is an example from MSDN.

The problem is I have come across many similar but different examples all over the web.

And if you look in Reflector at how people (inc MS) have implemented their TDBC you see different approaches again.

If you know of any article, example code, or library that you think shows the best practice for building TDBC please let me know.

Thanks

+2  A: 

I have read some in Developing Microsoft ASP.NET Server Controls and Components (Pro-Developer) (Paperback). It is pretty good, but out of date. It takes you through various aspects of building server controls, from dealing with state, to template fields.

A book that is more up-to-date, though I have not read it, is Professional ASP.NET 2.0 Server Control and Component Development (Wrox Professional Guides). I'm guessing it has similar content.

Of course, neither necessarily addresses best practices.

Greg Ogle
+1 strongly recommend the first book (by Nikhil Kothari, major authority on ASP.NET and great at explaining technical concepts). That book is perfect for learning the ins and outs of how controls are built.
Rex M
thanks for the answer. mods: given that I cant verify the answer (no access to the book) am I supposed to accept it anyway?
Schneider
DataBinding changed with .NET 2.0. That's when Data Source controls were added, along with two-way data binding. Great as the Kothari book is, it's for .NET 1.1.
John Saunders