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

Using Upload inside Grid

1 Answer 1043 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Kord
Top achievements
Rank 1
Kord asked on 26 Nov 2018, 04:33 AM

There is my table:

public class Sound
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    public Guid GUID { get; set; }
    [Display(Name = "Sound Type")]
    [Required]
    public SoundType SoundType { get; set; }
    [Display(Name = "Bandwidth, kHz")]
    public byte? Bandwidth { get; set; }
    [Display(Name= "Frequency, Hz")]
    public short? Frequency { get; set; }
    [Display(Name = "Duration, ms")]
    public short? Duration { get; set; }
    [Display(Name="Sound File")]
    public byte[] Content { get; set; }
    [Display(Name = "File Name")]
    public string FileName { get; set; }
    public Sound()
    {
        GUID = Guid.NewGuid();
    }
}

 

I just would like to show it in a grid and to be possible to upload files into the Content field and to store their names in the FileName field.

I've been trying to find out some examples of how to perform this, but almost all of them use separated steps to upload files into some directory on the server and to save the path to the file in the table then. I prefer to save the file attributes and its content as one step using Create or Update method of .

Is it possible to do it this way? Are there some examples?

Thank you.

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 26 Nov 2018, 01:05 PM
Hello,

If you have a separate view for the editor (e.g., in a custom popup template), you can have an upload there and store all fields in the same POST request. See how to use the uploaded file as a part of the form POST here: https://demos.telerik.com/aspnet-mvc/upload and you can extend the form to contain the rest of the inputs from the model.

You can find another example in the following code library entry: https://www.telerik.com/support/code-library/upload-in-grid-popup-editor.

If you will be using any sort of asyncronous file uploads, however, you'd need to store the file and its name somewhere on the server before the actual grid item edit happens, simply because that's an asyncronous operation. You can see how to add metadata to the uploads here so you can take the user ID from the client and send it together wit the file so you can immediately update the data source: https://www.telerik.com/forums/async-kendoupload-pass-custom-arguments-or-additional-data-to-mvc-controller.


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Upload
Asked by
Kord
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or