Search code examples
c#asp.net-mvcgrid.mvcmvcgrid

How to add two button in grid.mvc in Asp.Net mvc 5


I have a problem here I am using Grid.MVC I want to add two buttons with the different action links to View and Delete item.

Here is my code.

columns.Add().Titled("Option").Encoded(false)
                        .Sanitized(false)
                        .SetWidth("30%")
                        .RenderValueAs(o => (@<a href="@Url.Action("UserDetails", "Administration", new { id = o.UserID })">
                            <input type="button" class="btn btn-default" value="View" />
                        </a>) (@<a href="@Url.Action("NewInvestment", "Administration", new { id = o.UserID })">
                            <input type="button" class="btn btn-default" value="Delete" />
                        </a>));

Any one who understand Grid.MVC better. Please help me.


Solution

  • columns.Add().Titled("Option").Encoded(false)
                            .Sanitized(false)
                            .SetWidth("30%")
                            .RenderValueAs(o=>(                     
                                 Html.ActionLink("View","UserDetails", "Administration", new {id = o.UserID}, new {@class = "btn btn-default"}).ToHtmlString()
                                + Html.ActionLink("Delete","NewInvestment", "Administration", new {id = o.UserID}, new {@class = "btn btn-default"}).ToHtmlString()
                                )
                            );