Handling binary data

Docs

Binary data can be treated in one of two ways in the grid control. If it is an image then the value can be rendered directly in the browser by setting the column Image property using the ImageConfiguration class or if the binary data should be downloaded in the case of files such as spreadsheets or PDF's then you can set the column File property using the FileConfiguration class. The sample also demonstrates use of the OnConfigureBinaryData event which is used to assign a download file name to the binary data.

Preview binary data


Download binary data

Razor
                                
                                        
DbNetGridCore employeesGrid = new DbNetGridCore("northwind", "employees", "imageGrid")
{
    Columns = new List() { "EmployeeId", "FirstName", "LastName", "Title", "Photo", "PhotoPath" },
    PageSize = 5
};
employeesGrid.View = true;
employeesGrid.PageSize = 5;
employeesGrid.MaxImageHeight = 40;
employeesGrid.Bind(EventType.OnConfigureBinaryData, "configureImageFileName");
employeesGrid.Column("Photo").Image( new ImageConfiguration("jpg"));
@employeesGrid.Render()

DbNetGridCore downloadGrid = new DbNetGridCore("northwind", "employees", "downloadGrid")
{
    Columns = new List() { "EmployeeId", "FirstName", "LastName", "Title", "Photo", "PhotoPath" },
    PageSize = 5
};
downloadGrid.Column("EmployeeId").Hidden();
downloadGrid.Bind(EventType.OnConfigureBinaryData, "configureImageFileName");
downloadGrid.Column("Photo").File(new FileConfiguration("jpg"));
@downloadGrid.Render()