FormView: Can we have one template for EditItemTemplate, InsertItemTemplate and ItemTemplate?

  • Thread starter Thread starter Max2006
  • Start date Start date
M

Max2006

Hi,

I have a form that the contents of EditItemTemplate, InsertItemTemplate and
ItemTemplate are the same, so repeating the same content 3 times is
redundant. Is there any way to share all the contents?

Thank you,
Max
 
Yes, I often do that. I define one template with conditional rendering
at appropriate places depending on container's mode, and then in Init
event I assign this to other templates (like
FormView1.InsertItemTemplate = FormView1.UpdateItemTemplate).

Same goes for DataSource controls' update/insert parameter collections
(if those are reasonably similar), with difference being adjusted in
Init event.
 
However make sure doing this doesn't take away the feeling of multiple
instances of this template, as they can and will exist. Once I ruined
whole night in trying to debug a mysterious 'state loss' at insert
event, only to realize that there is (and should be) a new instance of
this template for update after insert :)
 
Yes, I often do that. I define one template with conditional rendering
at appropriate places depending on container's mode, and then in Init
event I assign this to other templates (like
FormView1.InsertItemTemplate = FormView1.EditItemTemplate).

Same goes for DataSource controls' update/insert parameter collections
(if those are reasonably similar), with difference being adjusted in
Init event.


However make sure doing this doesn't take away the feeling of multiple
instances of this template, as they can and will exist. Once I ruined
whole night in trying to debug a mysterious 'state loss' at insert
event, only to realize that there would be (and should be) new
instance of this template in update mode after insert :-)
 
Hi Max,

Muhammad's suggestions seems useful, have you tried it? Do you need
anything else in this question?


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top