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

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
 
M

Muhammad Naveed Yaseen

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.
 
M

Muhammad Naveed Yaseen

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 :)
 
M

Muhammad Naveed Yaseen

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 :)
 
W

Walter Wang [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top