How to display Images in grid using mvc.Grid

2.5k Views Asked by At

i have a mvc grid where i want to bind images which are saved as url in database.I am new to mvc grid.please help me out.Thanks..

This is the code:

@using GridMvc.Html
@Html.Grid(Model).Named("SalesDueOrderListPartial").Columns(columns =>
    {
        columns.Add(c => c.OrderNo).Titled("Order No").Filterable(true);
        columns.Add(c => c.ImageUrl).Titled("Image").Filterable(false);

    }).WithPaging(@ViewBag.paging).Sortable(true)
1

There are 1 best solutions below

1
Nitesh Kumar On

Try this

columns.Add().Encoded(false).Sanitized(false).Titled("Image").Filterable(false).RenderValueAs(c => @<div style="width:100px;"><img alt="Image" src='@c.ImageUrl')" /></div>);