Search code examples
asp.net-mvcwebgrid

how to handle wierd column format


I have the following in my webgrid:

grid.Column(header: "Action", 
        format: delegate(dynamic i)
                {
                    return Ajax.ActionLink("Remove", "SomeAction", new {dataId = @i.id},
                                new AjaxOptions
                                    {
                                        InsertionMode = InsertionMode.Replace,
                                        UpdateTargetId = "ropeDiv"
                                    });
                }
        )

and I want the contents of the column wrapped in a DIV... however I havent been able to get this to happen. I can do simple a simplet format where I am not needing a delegate... and I have seen a lot of simple formats. However nothing I have seen leads me to an answer on this.

I tried this:

grid.Column(header: "Action", 
        format: @<DIV> delegate(dynamic i)
                {
                    return Ajax.ActionLink("Remove", "SomeAction", new {dataId = @i.id},
                                new AjaxOptions
                                    {
                                        InsertionMode = InsertionMode.Replace,
                                        UpdateTargetId = "ropeDiv"
                                    });
                }
                </DIV>
        )

this didnt work ...

Any thoughts?


Solution

  • According to this article you could try this:

    grid.Column(header: "Action",
      format: @<div>@Ajax.ActionLink("Remove", "SomeAction", new{dataId=item.Id},
        new AjaxOptions
        {
          InsertionMode = InsertionMode.Replace,
          UpdateTargetId = "ropeDiv"
        })</div>
    )