M
Martin Simard
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?
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?