Pending Review
Last Updated: 11 Feb 2019 10:40 by ADMIN
Created on: 11 Feb 2019 10:24
Category: UI for ASP.NET AJAX
Type: Feature Request
GridAttachmentColumn passes malformed file path to the DataSource
GridAttachmentColumn malforms the String filepath, from "C\SomePath\SomeFile.PDF" to something like "C:" & vbBack &"SomePathSomeFile.PDF"

Steps to reproduce the error:

DataSource Bound to grid:

Private Function SomeTable() As DataTable
    Dim dt As New DataTable()
    dt.Columns.Add(New DataColumn("FieldName", Type.GetType("System.String")))
    row("FieldName") = "C:\SomeDirectory\RadGridExport.pdf"
    Return dt
End Function

GridAttachmentColumn markup as well as the ObjectDataSource that returns a byte array when user clicks on download attachment:

<telerik:GridAttachmentColumn DataSourceID="ObjectDataSource1"
    HeaderText="Attachment Column"
    ItemStyle-Width="36px" >
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="MySelectMethod" TypeName="MyApp">
        <asp:Parameter Name="FieldName" Type="String" />

MyApp.MySelectMethod that is supposed access the file by "filePath" and read it to byte, but the filePath is malformed, hence throws an exception.

Public Class MyApp
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)>
    Public Function MySelectMethod(filePath As String) As DataTable
        Dim dt As New DataTable("Base")
        Dim col As New DataColumn("FieldName")
        col.DataType = System.Type.GetType("System.Byte[]")
        Dim row As DataRow = dt.NewRow
        row(0) = My.Computer.FileSystem.ReadAllBytes(filePath)
        Return dt
    End Function
End Class