Multiple File Uploaded Problem

Last post 02-13-2009, 9:21 AM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  02-12-2009, 6:39 AM 48663

    Multiple File Uploaded Problem

    Hi,
     
    I am using the multiple file uploader with a manual start function - my problem is this:
     
    I've got a page where users can add a gallery - and on the same page I have a multiple file uploader where they can assign files to that gallery. All of the uploading etc is working but I cannot seem to get the ID of the newly added gallery.
     
    If I use the Uploader_FileUploaded method it adds a file to a new gallery each time not adding all the files to one gallery.
     
    I've got a submit button and was using SubmitButton_Click in codebehind to add the gallery using Scope_Identity and then Uploader_FileUploaded method to add the files to the gallery. Is the Uploader_FileUploaded method triggered before the SubmitButton_Click event?
     
    Sorry if this doesnt make any sense :-)
     
    Please let me know if you need any more information.
     
    thank you,
     
    Scott
  •  02-13-2009, 9:21 AM 48749 in reply to 48663

    Re: Multiple File Uploaded Problem

    Scott:
     
    Hi you may use this logic:
     
    void Uploader_FileUploaded(...)
    {
     
    int galleryid;
    object galleryidobj=ViewState["MyGalleryID"];
    if(galleryidobj==null)
    {
        galleryid=CreateNewGallery();
        ViewState["MyGalleryID"]=galleryid;
    }
    else
    {
        galleryid=(int)galleryidobj;
    }
     
    DoInsertFile(args,galleryid);

    }
     
    -----
     
    If you want to collect all files in the submit button event, I suggest you use the UploadAttachments control:
     
    void SubmitButton_Click(....)
    {
        int galleryid=CreateNewGallery();
        foreach(AttachmentItem item in new ArrayList(UploadAttachments1.Items))
        {
              if(!item.Checked)continue;
              DoInsertFile(galleryid,item);
              item.Delete();
        }
    }
     
    Regards,
    Terry
     
View as RSS news feed in XML