razormvccontribmvccontrib-grid

MVCContrib Grid Razor problem, Column.Action do not render


Code below works great with aspx view engine, i am trying to convert it to razor as below. Problem is first column do not show up.

I convert first column into link using action method. With razor it(first column) is not getting rendered in page at all. Rest of grid is fine.

What could be the problem?

@{Html.Grid(Model.Orders).Attributes(style => "width: 100%;").Columns(
column => {
    column.For(x => x.OrderNumber).Action(p => {
        @:<td>
        Html.ActionLink(
            p.OrderNumber.ToString(),
            "orderdetail",
            "OrderUpdate",
            new { id = p.OrderNumber, backUrl = Url.Action("OrderHistory", new { controller = "DataController", id = ViewData["id"] }) },
            new { });
        @:</td>
    }).HeaderAttributes(style => "text-align:left");

    column.For(x => x.OrderTimeV2).HeaderAttributes(style => "text-align:left");

    column.For(x => x.Status).HeaderAttributes(style => "text-align:left");

    column.For(x => x.Type).HeaderAttributes(style => "text-align:left");
}).RowStart((p, row) => { }).Render();}

Solution

  • I have moved away from using mvccontrib grid as it doesn't make much sense in grid we have.

    Anyway problem was code in the question does not return html but puts code directly into response stream. And code for columns rendered using razor which put's code into stream whenever called. so it ends up putting columns into stream before grid is rendered.

    It was resolved by not using razor code in action called by grid.