Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max2006 - 24 Aug 2007 22:25 GMT
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
Muhammad Naveed Yaseen - 26 Aug 2007 00:05 GMT
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.
Muhammad Naveed Yaseen - 26 Aug 2007 00:15 GMT
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 :)
Muhammad Naveed Yaseen - 26 Aug 2007 00:20 GMT
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 :-)
Walter Wang [MSFT] - 29 Aug 2007 14:24 GMT
Hi Max,

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

Regards,
Walter Wang (wawang@online.microsoft.com, 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.