Error after upgrade from 1.0 to 2.0

Last post 12-10-2008, 8:14 AM by msalti. 2 replies.
Sort Posts: Previous Next
  •  12-04-2008, 1:49 PM 46592

    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
  •  12-05-2008, 11:22 AM 46619 in reply to 46592

    Re: Error after upgrade from 1.0 to 2.0

    Moe,
     
    We support multiple uploads in the v2.0 , and changed server code to support this future.
     
    That changes cause your issue.
     
    Now I think the best solution for your code is that :
     
    this._isbinded=false; //decalre this member at the class code.
    this.Page.PreRenderComplete+=delegate{
       if(this._isbinded)return;
       this.FindParent<FieldEditor>().RefreshParent();
       this.FindParent<FieldEditor>().BindFields();
       this._isbinded=true;
    };
     
    Regards,
    Terry
  •  12-10-2008, 8:14 AM 46741 in reply to 46619

    Re: Error after upgrade from 1.0 to 2.0

    thanks terry, worked like a charm.
    Regards,

    Moe
View as RSS news feed in XML