DetailsView programmatically enter Insert Mode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don

    DetailsView programmatically enter Insert Mode

    I have a detailsView that I use with a GridView. When a row is
    selected I show the GridView with a default mode of Edit. This shows
    my fields with text boxes for changing the data. It also has the
    update and cancel buttons.

    Now I need to put the DetailsView into Insert mode when a button is
    clicked. In the button clicked event handler, in the code behind, I
    change to insert mode with this code:
    dvSingleRow.Cha ngeMode(Details ViewMode.Insert );

    This takes me into InsertMode but I do not see any of the fields. If
    I first select a row and then click the insert button I see all my
    fields.

    I am using autoGenerateRow s=true because by ObjectDataSourc e is
    dynamic and I may have different columns.
  • Phil H

    #2
    Re: DetailsView programmaticall y enter Insert Mode

    On 21 Feb, 21:44, Don <chambers...@ho tmail.comwrote:
    I have a detailsView that I use with a GridView.  When a row is
    selected I show the GridView with a default mode of Edit.  This shows
    my fields with text boxes for changing the data.  It also has the
    update and cancel buttons.
    >
    Now I need to put the DetailsView into Insert mode when a button is
    clicked.  In the button clicked event handler, in the code behind, I
    change to insert mode with this code:
    dvSingleRow.Cha ngeMode(Details ViewMode.Insert );
    >
    This takes me into InsertMode but I do not see any of the fields.  If
    I first select a row and then click the insert button I see all my
    fields.
    >
    I am using autoGenerateRow s=true because by ObjectDataSourc e is
    dynamic and I may have different columns.
    It may be that you need to execute the DataBind method in the code for
    the event handler so as to refresh databound controls in response to
    state changes.

    Comment

    • Don

      #3
      Re: DetailsView programmaticall y enter Insert Mode

      I tried that but still get the same results.
      I put a breakpoint in the DataBound event and I see that
      sender.DataItem is null when I call dataBind from by insert click
      event handler.

      On Feb 21, 5:14 pm, Phil H <goo...@philpha ll.me.ukwrote:
      On 21 Feb, 21:44, Don <chambers...@ho tmail.comwrote:
      >
      >
      >
      >
      >
      I have a detailsView that I use with a GridView.  When a row is
      selected I show the GridView with a default mode of Edit.  This shows
      my fields with text boxes for changing the data.  It also has the
      update and cancel buttons.
      >
      Now I need to put the DetailsView into Insert mode when a button is
      clicked.  In the button clicked event handler, in the code behind, I
      change to insert mode with this code:
      dvSingleRow.Cha ngeMode(Details ViewMode.Insert );
      >
      This takes me into InsertMode but I do not see any of the fields.  If
      I first select a row and then click the insert button I see all my
      fields.
      >
      I am using autoGenerateRow s=true because by ObjectDataSourc e is
      dynamic and I may have different columns.
      >
      It may be that you need to execute the DataBind method in the code for
      the event handler so as to refresh databound controls in response to
      state changes.- Hide quoted text -
      >
      - Show quoted text -

      Comment

      • fs241690@scarlet.be

        #4
        Re: DetailsView programmaticall y enter Insert Mode

        It can happen if the DetailsView is linked to a GridView witch
        SelectedIndex = -1.
        Did you try this ?

        GridView1.Selec tedIndex = 0;
        DetailsView1.Ch angeMode(Detail sViewMode.Inser t);




        Comment

        Working...