CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Members   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_parts_and_personalization Tags:
Item Type: NewsGroup Date Entered: 3/7/2006 10:51:47 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 26 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
pradeepy
Asp.Net User
The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.3/7/2006 10:51:47 PM

0/0

Hi,

I am trying create a webpart by inheriting from webpart class, like

Public Class   MyWebPart : WebPart

In the MyWebPart Class i am creating a GridView and adding it to the control collection as follows

 protected override void CreateChildControls()

{

  this.Page.Form.Controls.Add(grdMyGridView);

}

If i do so it is throwing an error .

The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.

How do i correct this error?? Please correct me  if i am going wrong somewhere!!

The reason i am using the syntax  this.Page.Form.Controls.Add(grdMyGridView) is if i don't add to Form it is giving an error that GridView should be placed inside a form

I would like to use EnableSortingAndpagingCallbacks feature of GridView.

Any furthur suggestions and comments are welcome.

 

mharder
Asp.Net User
Re: The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.3/10/2006 10:37:07 PM

0/0

You should add the GridView to your own controls collection, not to Page.Form.  Change your code to something like this:

protected override void CreateChildControls() {
    Controls.Add(grdMyGridView);
}

-Mike

http://blogs.msdn.com/mharder

This posting is provided "AS IS" with no warranties, and confers no rights.
pradeepy
Asp.Net User
Re: The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.3/11/2006 8:36:37 PM

0/0

MHarder sorry for the late reply. I have done as you have said.

But now it is giving the following error.

The GridView '' fired event Sorting which wasn't handled.

My snippet of code is as below

grd.EnableSortingAndPagingCallbacks = true;

grd.AllowPaging = true;

grd.AllowSorting = true;

Does EnableSortingAndPagingCallbacks property in GridView have problems using with webpart??.

When we set EnableSortingAndPagingCallbacks to true do we still need to handle sorting event of the GridView??

I think this is a bug in MicroSoft GridView Control?

Well, Please let me know your comments.

 

mharder
Asp.Net User
Re: The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.3/13/2006 6:54:23 PM

0/0

Can you reproduce this behavior without using WebParts?  If so, please post your question to the Data Presentation Controls forum (http://forums.asp.net/24/ShowForum.aspx).

-Mike

http://blogs.msdn.com/mharder

This posting is provided "AS IS" with no warranties, and confers no rights.
4 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

Explain layers.... - macromedia.flash.sitedesign - Web Programming ... Explain layers...., > ROOT > NEWSGROUP > Adobe-Macromedia Forums > macromedia.flash.sitedesign, Date: 2/19 ... the control collection cannot be modified ...
The control collection cannot be modified during DataBind, Init, Load ... The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases., > ROOT > NEWSGROUP > Asp.Net Forum > general_asp.net. ...
The control collection cannot be modified during DataBind, Init, Load ... DotNetNuke® ... cannot be modified during DataBind, Init, Load, PreRender or Unload phases. ... 5. Site Moderators have the final word on approving/removing a ...
The control collection cannot be modified during databind, Init, Load ... Telerik is a leading vendor of ASP.NET and Windows Forms ... The control collection cannot be modified during databind, Init, Load, PreRender or Unload phase ...
The control collection cannot be modified during databind, Init, Load ... The control collection cannot be modified during databind, Init, Load, PreRender or Unload phase ... The control collection cannot be modified during databind, ...
Problem with latest version 3.14 - Repository Module [Lead: Steve ... DotNetNuke® ... The control collection cannot be modified during DataBind, Init, Load, PreRender or ... 5. Site Moderators have the final word on approving/removing a ...
Custom Server Controls ... The control collection cannot be modified during ... The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases ...
ASP.NET RSS Toolkit - Home ... The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases. ... (0x80004005): The control collection cannot be ...


 
All Times Are GMT