Ticket Q495188
Visible to All Users

ASPxFileManager - How to get a file's SettingsDataSource.KeyFieldName field value

created 12 years ago

I have an ASPxFileManager that I bind to a datatable

<dx:ASPxFileManager AllowResize="true" ID="filemanager" runat="server" Theme="DevEx" EnableTheming="True" Width="100%" SettingsUpload-Enabled="false" OnCustomThumbnail="fileManager_CustomThumbnail" OnFileDownloading="filemanager_FileDownloading" >
<SettingsDataSource KeyFieldName="admin:id" ParentKeyFieldName="admin:parentid" NameFieldName="NameAndAttachment" IsFolderFieldName="IsFolder" />
     </dx:ASPxFileManager>

Both in my code-behind and on the client-side I want to access the KeyFieldName of the file or folder. In the event I can find the filename e.File.Name alright and some other fields, but I can't identify the KeyFieldName. On the client-side I'm even more hopelessly lost to find this
Can you please help me?

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hi Max,
The SettingsDataSource.KeyFieldName and SettingsDataSource.ParentKeyFieldName properties are used only to generate a File structure using the DataSource control. After the file structure is generated, the Key field is no longer used in APSxFileManager to identify files.
To accomplish your task, you can find the corresponding Key value in your data source manually by using the e.File.Name and e.File.RelativeName properties.
UPDATED:
I suggest you use ASPxFileManager.JSProperties to send the necessary properties value from the server to the client.
See Also:
- ASPxFileManager - How to implement custom thumbnails

    Show previous comments (5)
    Vasily (DevExpress Support) 12 years ago

      Hi Max,
      If I understand you correctly you want to store all your file IDs in the JSProperties collection, and then get the ID of the corresponded file by its name on the client side. In this case I suggest you pass the dictionary with the file names and corresponding ID fields to the client side by using the JSProperties collection:

      Visual Basic
      Protected Sub filemanager_CustomJSProperties(sender As Object, e As DevExpress.Web.ASPxClasses.CustomJSPropertiesEventArgs) Handles filemanager.CustomJSProperties Dim fileNames As Dictionary(Of String, String) = New Dictionary(Of String, String) 'Key="FileName" Value="ID" ... e.Properties("cpFileNames") = fileNames End Sub
      JavaScript
      function GetFileID(fileName) { return fileManager.cpFileNames[fileName]; }

        That was the break I needed. Thank you Vasily. It works.

        Vasily (DevExpress Support) 12 years ago

          Hi Max,
          Please do not hesitate to contact us in case of any difficulty. We will be happy to help you!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.