views:

82

answers:

1

I created a simple detail edit form earlier, and decided to data bind some controls on it. Of course, I was told they needed to be on a data bound container. My immediate, rather uninformed choice was a FormView. Is this appropriate? What containers could I use here?

Wrapping my controls in the ItemTemplate of the FormView of course made them inaccessible to my code, forcing me into many FindControls and casts, which is just untidy. I know I can write helpers and extension methods that make this much neater, but I just wanted a quick demo. Am I missing something regarding dealing with templated, and this 'nested' controls in this situation?

A: 

Your choices are the FormView or DetailsView controls. The primary difference between them is that DetailsView does all the work for you whereas FormView requires you to create your own templates, thus allowing greater control. As you've discovered, FormView requires using FindControl to access the controls, but the intent with data binding is that you shouldn't need to frequently access the controls directly.

Jamie Ide
My only real need to access controls is for cascading dropdown lists, but I think I will try and handle that all client side.
ProfK