views:

18

answers:

1

I understand that only one FormView template is rendered at any given time, so is it ever a problem to reuse child control IDs?

For example, the insert and edit templates are identical in this FormView, each has a TextBox in which a user may enter their name. Would it be a problem (or a bad idea) to give both text boxes the ID "NameTextBox"?

Better yet, is there a way I can create a single template that is used in both insert and edit modes? With the same code-behind, event handlers, etc? I found a forum thread somewhere that suggested creating a web user control to use in both insert and edit modes - is this typical?

+1  A: 

Yes, you can use the same ID in different FormView templates. This works exactly like the repeater controls which use templates.

However... there is no way that I know of to use a single template as both insert and edit modes. If you want to do that, why use a FormView at all? Just use a straight webform and handle the insert/edit logic yourself.

Bryan
Well, I could either take the trouble of duplicating the form for insert and edit views, or I could take the trouble of using a webform and handling the insert/edit logic. The advantage of the former is that I get display and empty data views out of a FormView too. Duplicating the insert/edit views is not really a big deal, I was just curious. Thanks!
Duke