コード例 #1
0
        /// <summary>
        /// Binds a list of files to a drop down list.
        /// </summary>
        /// <remarks></remarks>
        private void BindFileList()
        {
            lstAttachments.Items.Clear();

            AttachmentController  cntAttachment = new AttachmentController();
            List <AttachmentInfo> lstFiles      = null;

            if (PostId > 0)
            {
                lstFiles = cntAttachment.GetAllByPostID(PostId);
                //Check for "lost" uploads from previous uncompleted posts and add them to the list
                List <AttachmentInfo> lstTemp = cntAttachment.GetAllByUserID(UserId);
                if (lstTemp.Count > 0)
                {
                    lstFiles.AddRange(lstTemp);
                }
            }
            else
            {
                //Check for "lost" uploads from previous uncompleted posts and add them to the list
                lstFiles = cntAttachment.GetAllByUserID(UserId);
            }


            foreach (AttachmentInfo objFile in lstFiles)
            {
                ListItem lstItem = new ListItem();
                lstItem.Text  = objFile.LocalFileName;
                lstItem.Value = objFile.FileName;
                lstAttachments.Items.Add(lstItem);
                lstAttachmentIDs += objFile.AttachmentID.ToString() + ";";

                ViewState["attachment"] = objFile.AttachmentID;
            }
        }