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

Discussion in 'ASP .Net' started by Max2006, Aug 24, 2007.

  1. Max2006

    Max2006 Guest

    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
     
    Max2006, Aug 24, 2007
    #1
    1. Advertising

  2. 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, Aug 26, 2007
    #2
    1. Advertising

  3. 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, Aug 26, 2007
    #3
  4. 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 :)
     
    Muhammad Naveed Yaseen, Aug 26, 2007
    #4
  5. Hi Max,

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


    Regards,
    Walter Wang (, 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.
     
    Walter Wang [MSFT], Aug 29, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pjbates
    Replies:
    1
    Views:
    4,537
    Dan Vogt
    May 2, 2006
  2. Swetha
    Replies:
    0
    Views:
    3,704
    Swetha
    Nov 14, 2005
  3. jobs at webdos
    Replies:
    0
    Views:
    701
    jobs at webdos
    Oct 9, 2006
  4. Replies:
    1
    Views:
    870
    Mufasa
    May 19, 2008
  5. Andy B.
    Replies:
    0
    Views:
    886
    Andy B.
    Nov 25, 2009
Loading...

Share This Page