Reputation: 47743
Ok, I have a hyperlink on my page and that hyperlink is held within a user control. When the user clicks that link, it's used to remove an item on the page, so:
<a href='<%#string.Format("{0}?removeItem=true&ItemID={1}", CurrentPage, Container.DataItem.Id )%>'>Remove this item</a>
On click of the link, the code-behind of my user control checks for the removeItem bool and if set to true, removes that item:
removeSavedItem = Convert.ToBoolean(Request["removeItem"]);
if(removeItem)
RemoveItem();
And here's my RemoveItem() method:
protected void RemovItem()
{
int itemID = Util.ParamVal("savedItemID", 0);
if (itemID > 0)
service.RemoveItem(itemID);
}
But I need my page to refresh because it's removing it but my repeater is not showing the list with the item removed. What's the best way to approach this? Just do a rebind of the repeater or is there a cleaner way? Maybe that's just the standard way? Rebind after I remove it in this method?
Upvotes: 0
Views: 699
Reputation: 21991
I suggest trying to ajaxify the removal of the items, Unless you are changing a whole lot of things in the page.
As an answer to your question, you can do Response.Redirect(Request.Url.ToString());
Incase you want to do it from JavaScript for any reason then use window.location.reload();
Thanks
Upvotes: 1
Reputation: 8474
this is with pah and query
Response.Redirect(Request.Url.PathAndQuery);
Upvotes: 0
Reputation: 437
Why not save removed items in your session so that refresh will not pick up them?
Upvotes: 0
Reputation: 14713
I prefer to redirect back to the same page.
Response.Redirect(Request.Path);
Upvotes: 0