Problems with dynamically created GridView/DetailsView

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

Martin Simard

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.
 
M

Martin Simard

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top