This is a migrated thread and some comments may be shown as answers.

grid binary image

3 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chom
Top achievements
Rank 1
Chom asked on 22 Mar 2010, 05:32 PM
Hi

Is there a way to get the MIME, Content Type and file name from the grid binary image when uploading a file to a database?

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 23 Mar 2010, 08:27 AM

Hello Chom,

I guess you want to access the file properties in UpdateCommand of grid. If so you can use the following code snippet in order to achieve this.

C#:

 
    protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
        GridEditFormItem editItem = (GridEditFormItem)e.Item;  
        RadUpload upload = (RadUpload)editItem["BinaryImage1"].Controls[0];  
        string ContentType = upload.UploadedFiles[0].ContentType.ToString();  
        string name = upload.UploadedFiles[0].GetName();  
    } 

-Shinu.

0
Chom
Top achievements
Rank 1
answered on 24 Mar 2010, 04:02 PM
Hi Shinu

Thanks for that tip, it helped me a lot. I was kind of on the right track, but I was in a different event.

many thanks

Chom
0
Grant Millgate
Top achievements
Rank 1
answered on 09 Jun 2011, 10:08 PM
Helped me to. I put the data into hiddenfields and then used the hidden fields as control parameters

 Protected Sub RadGrid1_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
        Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
        Dim LogoImage As RadUpload = DirectCast(editItem("LogoImage").Controls(0), RadUpload)
        If LogoImage.UploadedFiles.Count > 0 Then
            Dim LogoContentType As String = LogoImage.UploadedFiles(0).ContentType.ToString()
            Dim LogoFilename As String = LogoImage.UploadedFiles(0).GetName()

            'copy values to cookies
            hfLogoContentType.Value = LogoContentType
            hfLogoFilename.Value = LogoFilename

        End If
       
        Dim SignatureImage As RadUpload = DirectCast(editItem("SignatureImage").Controls(0), RadUpload)
        If SignatureImage.UploadedFiles.Count > 0 Then
            Dim SignatureContentType As String = SignatureImage.UploadedFiles(0).ContentType.ToString()
            Dim SignatureFilename As String = SignatureImage.UploadedFiles(0).GetName()

            'copy values to cookies
            hfSignatureContentType.Value = SignatureContentType
            hfSignatureFilename.Value = SignatureFilename
        End If
       

    End Sub





   <asp:Parameter Name="LogoImage" dbType="binary" />
             <asp:Parameter Name="signatureimage"  DbType="Binary"/>

            <asp:ControlParameter ControlID="hfLogoFilename" Name="LogoFilename"
                PropertyName="Value" />
            <asp:ControlParameter ControlID="hfLogoContentType" Name="LogoContentType"
                PropertyName="Value" />
            <asp:ControlParameter ControlID="hfSignatureFilename" Name="signaturefilename"
                PropertyName="Value" />
            <asp:ControlParameter ControlID="hfSignatureContentType"   Name="SignatureContentType" PropertyName="Value" />
Tags
Grid
Asked by
Chom
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Chom
Top achievements
Rank 1
Grant Millgate
Top achievements
Rank 1
Share this question
or