In my visual studio 2015 mvc web application, I need to create (append) the successful Ajax return data and append them to a webgrid, but the following code don't compile, the code of dataval (id = dataval.id) within the var html can not be recognized (compiled).
Does anybody know how to make it working? basically, I need to create those Html.ActionLink with other data returned from ajax call.
$.each(response, function (j, dataval) {
var html='@Html.Raw(HttpUtility.HtmlDecode(Html.ActionLink("Edit", "Edit", new { id = dataval.id }).ToHtmlString()))';
html+='@Html.Raw(HttpUtility.HtmlDecode(Html.ActionLink("create", "Create", new { id = dataval.id }).ToHtmlString()))';
html+='@Html.Raw(HttpUtility.HtmlDecode(Html.ActionLink("Invoice", "Invoice", new { id = dataval.id }).ToHtmlString()))';
html+='@Html.Raw(HttpUtility.HtmlDecode(Html.ActionLink("Delete", "Delete", new { id = dataval.id }).ToHtmlString()))';
$("#GridProductIndex").append('<tr><td>' + dataval.Prod_Name + '</td> + <td>' + dataval.Prod_Type + '</td> +<td>' + dataval.Prod_Status + '</td><td>' +
html + '</td></tr>');
});
Added more, here is the webgrid I want to append the above data to:
grid.Columns(
grid.Column(columnName: "Prod_Name", header: "Product Name"),
grid.Column(columnName: "Prod_Type", header: "Type"),
grid.Column(columnName: "Prod_Status", header: "Status"),
grid.Column(header: "Actions", format: (item) =>
new HtmlString(
Html.ActionLink("Edit", "Edit", new { id = item.ID }).ToString() + " | " +
Html.ActionLink("create", "Create", new { id = item.ID }).ToString() + " | " +
Html.ActionLink("Invoice", "Invoice", new { id = item.ID }).ToString() + " | " +
Html.ActionLink("Delete", "Delete", new { id = item.ID }).ToString()
), style: "Action"
)