Error after upgrade from 1.0 to 2.0

  •  12-04-2008, 1:49 PM

    Error after upgrade from 1.0 to 2.0

    Hi,
     
    I have a cute uploader on a user control which is in turn within a repeater control. When a file is uploaded the parent repeater control is forced to do a databind. In version 1.0 this worked just fine, but unfortunately it crashes with the following message in version 2.0.
     
    "The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases."
     
    here is a code snippet within my FileUploaded event.
     
     if (!field.NoOverride)
             {
                using (System.IO.Stream stream = args.OpenStream())
                {
                   field.FieldBinaryValue = new byte[args.FileSize];
                   stream.Read(field.FieldBinaryValue, 0, args.FileSize);
                }
                field.Save();

                string jScript = "alert('The file was successfully uploaded.');";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), jScript, true);
             }

             this.FindParent<FieldEditor>().RefreshParent();
             this.FindParent<FieldEditor>().BindFields(); //rebinds the repeater the uploader is in
     
     
    Any help is apperciated!
     
    Thanks,
     
    Moe
     
     

    Regards,

    Moe
View Complete Thread