Hello sir,
i want to refresh webgrid after delete recode i have used redirection to that view is this write or should i use other method?
<body>
hello
@{
var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5,
selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent");
grid.Pager(WebGridPagerModes.NextPrevious);}
<div id="gridContent">
@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(
grid.Column("Id", format: (item) => item.GetSelectLink(item.ProductId)),
grid.Column("Name", "Name"),
grid.Column("Price", "Price"),
grid.Column("BrandId", "BrandId"),
grid.Column(format: (item) => Html.ActionLink("Edit", "EditProductData", new { Id = item.ID })),
grid.Column(format: (item) => Html.ActionLink("Delete", "DeleteProductData", new { Id = item.ID })),
grid.Column(format: (item) => Html.ActionLink("Direct Delete", "WebGridDemo", "Product", null, new { onclick = "delMeal(" + item.Id + ")" }))
))
</div>
@{
MvcApplication1.Models.Product product = new MvcApplication1.Models.Product();
}
@if (grid.HasSelection)
{
product = (MvcApplication1.Models.Product)grid.Rows[grid.SelectedIndex].Value;
<b>Id</b> @product.Id<br />
<b>Name</b> @product.Name<br />
<b>Price</b> @product.Price<br />
<b>BrandID</b> @product.BrandId<br />
@* <b>Quantity</b> @product.Quantity<br />*@
}
</body>
<script>
function delMeal(pid) {
if (confirm("Do you want to delete Meal: " + pid)) {
$.ajax({
type: "POST",
url: '/Product/DeleteProductDataDirectly',
data: { Id: pid },
dataType: "json",
success: function () { alert('Success') }
});
}
}
</script>