|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problems with dynamically created GridView/DetailsViewI 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? 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. I'm running into the same problem. Have you resolved this Martin?
Show quoteHide quote "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? > > > 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 Show quoteHide quote "Grim" <G***@discussions.microsoft.com> wrote in message news:0D6C3001-8143-442E-9CE2-848DB85ABDD6@microsoft.com... > 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? >> >> >>
How to get ListItemValue and ListItemText from a Combo using SendMessage
Fitting a table inside an ASP Panel checkbox bind with 0 = checked? error using .NET CrystalReportViewer (.NET 1.1 VS.NET 2003) Removing columns from Gridview(2.0) databinding on templatefileds dont work? Rendering a Treeview Control InputAttributes in RowCreated (gridview) GridView XmlDataSource GridView Height WebControl rendering in frontpage 2003 - Migrating from Visual Studio 2003 to 2005 |
|||||||||||||||||||||||