سؤال

I am concatenating three columns of my model and displaying them as one as action link which calls a method of controller.I write some code which is giving errors that item does not exist in current context and The best overloaded method match for System.Web.Helpers.WebGrid.Column(string, string, System.Func<dynamic,object>, string, bool) has some invalid arguments.

View :

             @using (Html.BeginForm()) {
             @Html.ValidationSummary(true)
             var grid = new WebGrid(source: Model,
                         rowsPerPage: 3);

        <div id="grid">
        @grid.GetHtml(
            columns: grid.Columns(
                   grid.Column("street", format: Html.ActionLink(item.street+ ' ' + item.city+ ' ' + item.propertyType, "showDetails" , "SearchSpace", new{ spaceId = item.spaceId})
                )
                )

                )
    </div>
}
هل كانت مفيدة؟

المحلول

Try and see if it works:

 grid.Column(header: "YourColumnName", format: (item) =>new HtmlString(
                        Html.ActionLink("linkText", "actionName","controllerName", new { id = item.yourItemId },null).ToString()))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top