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.