Detailsview: Is it possible to share templatefields

Discussion in 'ASP .Net' started by Ole Kirkholt, Sep 25, 2008.

  1. Ole Kirkholt

    Ole Kirkholt Guest

    Hello

    I'm starting on my first asp.net project.
    I'm using VS2008sp1 and .Net 3.5

    I'm trying to create a page for inserting/editing a single databaserecord

    I need both multiline textboxes, check- and listboxes.
    To do that I need templatefields, right ?

    Is there a way to share the same templatefield between inserting and editing,
    so I don't have til make everything (including validation controls) twice ?

    Best Regards

    Ole
     
    Ole Kirkholt, Sep 25, 2008
    #1
    1. Advertising

  2. Ole Kirkholt

    cmeek1_1999 Guest

    If you do not specify an inserting template, the editing template will be used.
    The save button needs an "insert" or "update" string, so you can create
    a protected property UpdateOrInsert which returns
    FormView1.CurrentMode != FormViewMode.Insert ? "Update" : "Insert";
    Specify CommandName='<%# UpdateOrInsert %>' for the save button.

    Regards,

    Carlo Mekenkamp

    "Ole Kirkholt" wrote:

    > Hello
    >
    > I'm starting on my first asp.net project.
    > I'm using VS2008sp1 and .Net 3.5
    >
    > I'm trying to create a page for inserting/editing a single databaserecord
    >
    > I need both multiline textboxes, check- and listboxes.
    > To do that I need templatefields, right ?
    >
    > Is there a way to share the same templatefield between inserting and editing,
    > so I don't have til make everything (including validation controls) twice ?
    >
    > Best Regards
    >
    > Ole
     
    cmeek1_1999, Sep 25, 2008
    #2
    1. Advertising

  3. Ole Kirkholt

    Ole Kirkholt Guest

    Hello again

    I have tried this, but it is not working on inserts.

    When I want to insert a record by setting the formview's defaultmode to
    Insert, the property isn't read, and therefore the commandtext isn't updated.

    Is there any other way/event that can be used to set the CommandText of a
    linkbutton, of to force the form til save the new record ?¨

    Best Regards

    Ole Kirkholt



    "cmeek1_1999" wrote:

    > If you do not specify an inserting template, the editing template will be used.
    > The save button needs an "insert" or "update" string, so you can create
    > a protected property UpdateOrInsert which returns
    > FormView1.CurrentMode != FormViewMode.Insert ? "Update" : "Insert";
    > Specify CommandName='<%# UpdateOrInsert %>' for the save button.
    >
    > Regards,
    >
    > Carlo Mekenkamp
    >
    > "Ole Kirkholt" wrote:
    >
    > > Hello
    > >
    > > I'm starting on my first asp.net project.
    > > I'm using VS2008sp1 and .Net 3.5
    > >
    > > I'm trying to create a page for inserting/editing a single databaserecord
    > >
    > > I need both multiline textboxes, check- and listboxes.
    > > To do that I need templatefields, right ?
    > >
    > > Is there a way to share the same templatefield between inserting and editing,
    > > so I don't have til make everything (including validation controls) twice ?
    > >
    > > Best Regards
    > >
    > > Ole
     
    Ole Kirkholt, Sep 26, 2008
    #3
  4. Ole Kirkholt

    cmeek1_1999 Guest

    Dit you use a FormView1.DataBind()?
    In the PageLoad I mostly DataBind all controls:
    if (!IsPostBack)
    {
    FormView1.DataBind();
    }


    "Ole Kirkholt" wrote:

    > Hello again
    >
    > I have tried this, but it is not working on inserts.
    >
    > When I want to insert a record by setting the formview's defaultmode to
    > Insert, the property isn't read, and therefore the commandtext isn't updated.
    >
    > Is there any other way/event that can be used to set the CommandText of a
    > linkbutton, of to force the form til save the new record ?¨
    >
    > Best Regards
    >
    > Ole Kirkholt
    >
    >
    >
    > "cmeek1_1999" wrote:
    >
    > > If you do not specify an inserting template, the editing template will be used.
    > > The save button needs an "insert" or "update" string, so you can create
    > > a protected property UpdateOrInsert which returns
    > > FormView1.CurrentMode != FormViewMode.Insert ? "Update" : "Insert";
    > > Specify CommandName='<%# UpdateOrInsert %>' for the save button.
    > >
    > > Regards,
    > >
    > > Carlo Mekenkamp
    > >
    > > "Ole Kirkholt" wrote:
    > >
    > > > Hello
    > > >
    > > > I'm starting on my first asp.net project.
    > > > I'm using VS2008sp1 and .Net 3.5
    > > >
    > > > I'm trying to create a page for inserting/editing a single databaserecord
    > > >
    > > > I need both multiline textboxes, check- and listboxes.
    > > > To do that I need templatefields, right ?
    > > >
    > > > Is there a way to share the same templatefield between inserting and editing,
    > > > so I don't have til make everything (including validation controls) twice ?
    > > >
    > > > Best Regards
    > > >
    > > > Ole
     
    cmeek1_1999, Sep 27, 2008
    #4
    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. Robert Fernandez

    Objects disappear in TemplateFields on postback

    Robert Fernandez, Apr 2, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    2,819
    Robert Fernandez
    Apr 2, 2007
  2. Feege
    Replies:
    0
    Views:
    503
    Feege
    Dec 20, 2005
  3. Saraswati lakki
    Replies:
    0
    Views:
    1,427
    Saraswati lakki
    Jan 6, 2012
  4. Jack
    Replies:
    2
    Views:
    246
  5. Eric Wong
    Replies:
    0
    Views:
    226
    Eric Wong
    Feb 13, 2010
Loading...

Share This Page