Populate dropdownlist with files in a directory


















DataBind drp. Exists folderPath Then Directory. IsNullOrEmpty Request. GetExtension filePath ; switch fileExtension.

Write File. ReadAllText filePath ; break; case ". WriteFile filePath ; Response. End ; break; case ". Load If Not String. ToLower Case ". ReadAllText filePath Case ". WriteFile filePath Response. End Case ". Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions.

Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings. I created a screenshot to clarify what I'm trying to accomplish. While viewing a SPO list, a user clicks "Add new item" and sees this form. For the File field, it is not a free-form text field but rather is a drop-down menu populated with files from a doc library. After a user selects one file from the drop-down menu, the file name would be added to the form.

Is this possible in SPO? I finally understand, thank you for clarifying. You could use a calculated column for this but based on the screenshot you sent me it looks like you want to populate the item Title column.

This means you probably need a workflow that would populate the title field when an item is submitted. You would also need to make title not required for this to work. You could use SharePoint workflow for this but MS flow might be a better longer term solution.

I hope this helps! Thanks for the quick response. Don't worry about how the other fields are populated e. How would I populate the drop-down menu with the names of the files in a specific doc library? That is the question I need solved. Have you tried creating a Lookup column?

The lookup column would be created in your list and would lookup the Title field from your Document Library. In your document library, you could setup a workflow that automatically sets the Title field value to equal the actual file name. Thanks Kevin McKeown - The lookup column is a great idea. I tried using an existing doc library and then tried with the default documents library and neither one offered "Name" as a column to choose from. Both document libraries have a "Name" column but it simply doesn't appear in the drop-down for a lookup column.

BTW I first tried using the "Title" field but it did not contain any data even though there are files in that library. As you are seeing, by default the Title field in a document library does not get a value applied to it only the Name field does. This is where the workflow comes in. You can have a workflow triggered on item creation in your document library. This workflow should be configured to copy the document Name field value into the Title field for that document. This way you will see Title values in your lookup column.

Thanks Kevin McKeown.



0コメント

  • 1000 / 1000