Problems with dynamically created GridView/DetailsView

Discussion in 'ASP .Net Web Controls' started by Martin Simard, Apr 3, 2006.

  1. Hello there,

    I have some problems when trying to create dynamically (in code behind) a
    GridView and DetailsView. Both datasources of the controls are
    ObjectDataSource objects.

    First problem, when I run my page I got the following error when I click the
    "Edit" button in the DetailsView: The DetailsView 'DetailsView' fired event
    ModeChanging which wasn't handled (why?)

    I then create the corresponding handler, but the DetailsView refuses to get
    in EditMode. I have to add the following code in the handler:
    detailsControl.ChangeMode(e.NewMode); I can now edit my field values, but
    other problems follow.

    When I click the UpdateButton, it fires the ItemUpdating event handler of my
    DetailsView, but the DetailsViewUpdateEventArgs contains nothing. No
    NewValues, no OldValues... just empty.

    I'm a little bit confused now, since everything works fine when I create the
    same page at design time dragging and dropping the
    GridView/DetailsView/ObjectDataSource and setting the properties/events.
    Both pages contain the same controls, same properties, but different
    behaviours.

    Maybe I'm missing something in dynamic controls creation. I tried to create
    my controls in the Page.OnPreInit and the Page.CreateChildControls methods.
    My databings are done in the Page.PreRender method. I tried severals things,
    and nothings seems to work. DataBinding problem? ViewState?

    Any idea someone?
     
    Martin Simard, Apr 3, 2006
    #1
    1. Advertising

  2. When I say "dynamically created", I mean that it is a composite control. My
    control inherits from WebControl and all controls in it (including the
    GridView and the DetailsView) are created programmatically.
     
    Martin Simard, Apr 3, 2006
    #2
    1. Advertising

  3. Martin Simard

    Grim Guest

    I'm running into the same problem. Have you resolved this Martin?

    "Martin Simard" wrote:

    > Hello there,
    >
    > I have some problems when trying to create dynamically (in code behind) a
    > GridView and DetailsView. Both datasources of the controls are
    > ObjectDataSource objects.
    >
    > First problem, when I run my page I got the following error when I click the
    > "Edit" button in the DetailsView: The DetailsView 'DetailsView' fired event
    > ModeChanging which wasn't handled (why?)
    >
    > I then create the corresponding handler, but the DetailsView refuses to get
    > in EditMode. I have to add the following code in the handler:
    > detailsControl.ChangeMode(e.NewMode); I can now edit my field values, but
    > other problems follow.
    >
    > When I click the UpdateButton, it fires the ItemUpdating event handler of my
    > DetailsView, but the DetailsViewUpdateEventArgs contains nothing. No
    > NewValues, no OldValues... just empty.
    >
    > I'm a little bit confused now, since everything works fine when I create the
    > same page at design time dragging and dropping the
    > GridView/DetailsView/ObjectDataSource and setting the properties/events.
    > Both pages contain the same controls, same properties, but different
    > behaviours.
    >
    > Maybe I'm missing something in dynamic controls creation. I tried to create
    > my controls in the Page.OnPreInit and the Page.CreateChildControls methods.
    > My databings are done in the Page.PreRender method. I tried severals things,
    > and nothings seems to work. DataBinding problem? ViewState?
    >
    > Any idea someone?
    >
    >
    >
     
    Grim, Apr 20, 2006
    #3
  4. Hi Grim,

    I have not resolved this yet. Unfortunately, I put this on hold for a few
    weeks.

    But I'm still looking for a solution. Our web applications are actually
    designed to generate webcontrols on the fly (under VS 2005 .NET 1.1). We
    developed a lot of composite controls in a few class libraries which are
    reused in different web applications (create dynamically on web forms).

    Since then, I looked at the following topic to find new ways of designing
    reusable webforms and webcontrols:
    http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx

    Anyway, we're looking forward to port our actual applications under VS 2005
    / .NET 2.0 and use the new controls and we're still facing the problem
    described under.

    I hope someone has a solution (or at least a hint) for us.

    Martin


    "Grim" <> wrote in message
    news:...
    > I'm running into the same problem. Have you resolved this Martin?
    >
    > "Martin Simard" wrote:
    >
    >> Hello there,
    >>
    >> I have some problems when trying to create dynamically (in code behind) a
    >> GridView and DetailsView. Both datasources of the controls are
    >> ObjectDataSource objects.
    >>
    >> First problem, when I run my page I got the following error when I click
    >> the
    >> "Edit" button in the DetailsView: The DetailsView 'DetailsView' fired
    >> event
    >> ModeChanging which wasn't handled (why?)
    >>
    >> I then create the corresponding handler, but the DetailsView refuses to
    >> get
    >> in EditMode. I have to add the following code in the handler:
    >> detailsControl.ChangeMode(e.NewMode); I can now edit my field values,
    >> but
    >> other problems follow.
    >>
    >> When I click the UpdateButton, it fires the ItemUpdating event handler of
    >> my
    >> DetailsView, but the DetailsViewUpdateEventArgs contains nothing. No
    >> NewValues, no OldValues... just empty.
    >>
    >> I'm a little bit confused now, since everything works fine when I create
    >> the
    >> same page at design time dragging and dropping the
    >> GridView/DetailsView/ObjectDataSource and setting the properties/events.
    >> Both pages contain the same controls, same properties, but different
    >> behaviours.
    >>
    >> Maybe I'm missing something in dynamic controls creation. I tried to
    >> create
    >> my controls in the Page.OnPreInit and the Page.CreateChildControls
    >> methods.
    >> My databings are done in the Page.PreRender method. I tried severals
    >> things,
    >> and nothings seems to work. DataBinding problem? ViewState?
    >>
    >> Any idea someone?
    >>
    >>
    >>
     
    Martin Simard, Apr 25, 2006
    #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. tfsmag
    Replies:
    1
    Views:
    4,763
    tfsmag
    Mar 14, 2006
  2. JaM
    Replies:
    2
    Views:
    2,965
  3. ami
    Replies:
    2
    Views:
    1,229
    Valerio Santinelli
    May 30, 2007
  4. msimmons
    Replies:
    0
    Views:
    516
    msimmons
    Jul 16, 2009
  5. Feege
    Replies:
    0
    Views:
    490
    Feege
    Dec 20, 2005
Loading...

Share This Page