views:

54

answers:

1

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{LoadingElementId="status"}) %>

I used above code its working fine (it delete record) but it doesn't update table.

A: 

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.

tvanfosson
this technique is not working. if you have code then please send me on my email address [[email protected]]
Xulfee
@Xulfee -- what seems to be the problem?
tvanfosson
my table is not update with new changes.
Xulfee