Update Table in Asp.Net MVC
I have table [HTML Table] on page I want to delete record from table and also update table after deletion record.
<%= Ajax.ActionLink("Delete Ajax", "PostTypeDelete",new { id = item.int_PostTypeId },
new AjaxOptions{LoadingElemen开发者_运维技巧tId="status"}) %>
I used above code its working fine (it delete record) but it doesn't update table.
The action needs to return a new copy of the table minus the deleted row and you need to give the id of the table to the extension method as part of the AjaxOptions (UpdateTargetId) so it knows which element to replace with the response from the action.
<%= Ajax.ActionLink("Delete Ajax",
"PostTypeDelete",new { id = item.int_PostTypeId },
new AjaxOptions
{
LoadingElementId="status",
UpdateTargetId="tableid"
}) %>
Alternatively -- if the entire table is always rendered, i.e., you will never have new rows appearing due to the current row being deleted -- you can omit returning the table and have a completed handler that simply removes the row in question from the table. In that case you might want to return just an empty row with the same id as the current row and use a handler to remove it when the action returns.
精彩评论